# BulkProcessor.awaitClose() is returning false and documents are getting indexed

**URL:** <https://discuss.elastic.co/t/bulkprocessor-awaitclose-is-returning-false-and-documents-are-getting-indexed/240176>\
**Category:** Elasticsearch\
**Created:** [July 7, 2020, 2:00pm UTC](https://discuss.elastic.co/t/bulkprocessor-awaitclose-is-returning-false-and-documents-are-getting-indexed/240176 "2020-07-07T14:00:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sanyukta\_Sinha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sanyukta_sinha/32/71740_2.png) [@Sanyukta\_Sinha](https://discuss.elastic.co/u/Sanyukta_Sinha)\
**Post date:** [July 7, 2020, 2:00pm UTC](https://discuss.elastic.co/t/bulkprocessor-awaitclose-is-returning-false-and-documents-are-getting-indexed/240176/1 "2020-07-07T14:00:48Z")

</div>

I am using bulkProcessor to index multiple UpdateRequests. The awaitClose() is returning false and hence the logs of the listener are not printing. The documents are still getting indexed but in the absence of the BulkResponse's logs of the listener, I am not sure whether all the documents got processed or some failed to do so. My question is that what can be the possible reasons awaitClose is returning false. Is there a way it can be true. And how to get the BulkResponse logs in such a scenario.

```auto
public static BulkProcessor.Builder getBulkProcessorBuilder(RestHighLevelClient restHighLevelClient) {
        BulkProcessor.Builder builder = BulkProcessor.builder((request, bulkListener) -> {
            try {
                restHighLevelClient.bulk(request, RequestOptions.DEFAULT);
            } catch (IOException e) {
                log.error("Failed to obtain Bulk Response ", e);
            }
        }, getBulkProcessorListener());

        return builder;
    }

```

```auto
public void bulkIndex(List<UpdateRequest> updateRequestList) {
        BulkProcessor bulkProcessor = ElasticSearchBulkProcessorBuilder
                .getBulkProcessorBuilder(restHighLevelClient)
                .build();
        updateRequestList
                .stream()
                .forEach(updateRequest -> bulkProcessor.add(updateRequest));

        try {
            boolean terminated = bulkProcessor.awaitClose(10L, TimeUnit.SECONDS);
            if (!terminated) {
                log.info("Some requests have not been processed. Closing bulkProcessor is timed-out.");
            } else {
                log.info("Closing bulkProcessor is executed successfully");
            }
        } catch (InterruptedException e) {
            log.error("awaitclose failed : ", e);
        }
    }

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 4, 2020, 2:00pm UTC](https://discuss.elastic.co/t/bulkprocessor-awaitclose-is-returning-false-and-documents-are-getting-indexed/240176/2 "2020-08-04T14:00:52Z")

</div>

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