Delete async on response of update async does not work

Hi all and sorry for my poor english
I'm calling an updateAsync with an action listener bind.
So I 'm calling a delete Async onResponse AND onFailure of previous async update but delete async is not excecuted correctly.
I got exception
`Request cannot be executed i/o reactor status stopped
Thnx in advance for your help

It'd be useful if you could provide the request you are making, as well as the complete response you received.

I can post you my code implementation

 public void updateByQueryRequestFinal(
            final long fromMillis,
          final String indexName, String dateFormat) throws IOException {
    String dateFormatted = DateHelper.format(new Date(fromMillis), dateFormat);
    log.debug("BEGIN updateByQueryRequestFinal from date {} on index:{}",
            dateFormatted, indexName);
    UpdateByQueryRequest updateByQueryRequest = new UpdateByQueryRequest(indexName);
    updateByQueryRequest.setScript(
            new Script(
                    ScriptType.INLINE, "painless",
                    "if (ctx._source.activities!=null)    \n" +
                            "                {   \n" +
                            "                    ArrayList  activities=ctx._source.activities;\n" +
                            "                    for (int i=activities.length-1; i>=0; i--) {\n" +
                            "                      if (activities[i].creationDate.compareTo('"+dateFormatted+"')<=0) {\n" +
                            "                          activities.remove(i);\n" +
                            "                         \n" +
                            "                      }\n" +
                            "                       \n" +
                            "                    }\n" +
                            "                     \n" +
                            "                   \n" +
                            "                     ctx._source.activities=activities;\n" +
                            "                    \n" +
                            "                }",
                    Collections.emptyMap()));
    final ActionListener actionListener = new ActionListener() {

      @SneakyThrows
      @Override
      public void onResponse(final Object o) {
        log.debug("The Old {} correctly updated", indexName);
        deleteByQueryRequestActivitiesEmpty(indexName);
      }

      @Override
      public void onFailure(final Exception e) {
        log.warn("The update of old {} raised an exception:{} ", indexName, e.getCause().toString());
        deleteByQueryRequestActivitiesEmpty(indexName);
      }
    };
    //client.updateByQuery(updateByQueryRequest, RequestOptions.DEFAULT);//,actionListener);
    client.updateByQueryAsync(updateByQueryRequest, RequestOptions.DEFAULT,actionListener);
    log.debug("END updateByQueryRequestFinal on index:{}", indexName);

and onFailure or onResponse I call

public void deleteByQueryRequestActivitiesEmpty(

          final String indexName )   {


    log.debug("BEGIN deleteByQueryRequestActivitiesEmpty  on index:{}",
             indexName);
    final DeleteByQueryRequest request =
            new DeleteByQueryRequest(indexName);
    request.setTimeout(TimeValue.timeValueMinutes(60));
    request.setRefresh(true);
    final QueryBuilder boolQueryBuilder = new BoolQueryBuilder()
            .mustNot(nestedQuery("activities",existsQuery("activities"), ScoreMode.Total));
    request.setQuery(boolQueryBuilder);
    log.debug("BEGIN deleteByQuery deleting");
    final ActionListener actionListener = new ActionListener() {
      @Override
      public void onResponse(final Object o) {
        log.debug("The Old {} correctly deleted", indexName);
      }

      @Override
      public void onFailure(final Exception e) {
        log.warn("The Deletion of old {} raised an exception:{} ", indexName, e.getCause().toString());
      }
    };
    //client.deleteByQuery(request, RequestOptions.DEFAULT);

    client.deleteByQueryAsync(request, RequestOptions.DEFAULT,actionListener);
    log.debug("END deleteByQueryRequestActivitiesEmpty on index:{}", indexName);
  }

The strange thing is that if I excecute them separately, they do their job correctly. It looks something related to RestHighLevelClient (may concurrent usage?)

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.