# Java Client Batch API , missing invocation of afterBulk

**URL:** https://discuss.elastic.co/t/java-client-batch-api-missing-invocation-of-afterbulk/40115
**Category:** Elasticsearch
**Created:** [January 26, 2016, 12:22pm UTC](https://discuss.elastic.co/t/java-client-batch-api-missing-invocation-of-afterbulk/40115 "2016-01-26T12:22:27Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Landong.Zuo](https://avatars.discourse-cdn.com/v4/letter/l/43a26b/32.png) [@Landong.Zuo](https://discuss.elastic.co/u/Landong.Zuo)
#### Post date: [January 26, 2016, 12:22pm UTC](https://discuss.elastic.co/t/java-client-batch-api-missing-invocation-of-afterbulk/40115/1 "2016-01-26T12:22:27Z")

</div>

Hi,

I am running ElasticSearch V2.1.0 on a single node machine and TransportClient at client side.  
The bulk process bulider was set with following parameters:  
.setBulkActions(1000)  
.setBulkSize(new ByteSizeValue(1, [ByteSizeUnit.GB](http://ByteSizeUnit.GB)))  
.setFlushInterval(TimeValue.timeValueSeconds(5))  
.setConcurrentRequests(1)  
.build();

The data update process went through correctly except the last bulk API call, whose call back functions were invoked inconsistently, in some occasion no callback (success or failure) was ever returned in 5 minutes.

I understand the last call always has less than 1000 requests, but would that make any difference to the call back? very weird! any clues?

Thanks,

Landong

---

<div class="post-metadata">

### Author: ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)
#### Post date: [January 26, 2016, 2:14pm UTC](https://discuss.elastic.co/t/java-client-batch-api-missing-invocation-of-afterbulk/40115/2 "2016-01-26T14:14:01Z")

</div>

Hi,

did you close the bulk processor after adding all documents either via:

```auto
bulkProcessor.awaitClose(10, TimeUnit.MINUTES);

```

or

```auto
bulkProcessor.close();

```

The bulk processor should then send all remaining documents and perform internal clean up.

Daniel

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [January 26, 2016, 2:15pm UTC](https://discuss.elastic.co/t/java-client-batch-api-missing-invocation-of-afterbulk/40115/3 "2016-01-26T14:15:58Z")

</div>

If I understand correctly and IIRC you have to call close() method when you shutdown your client.

It should flush the remaining items.

---

<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: [July 5, 2017, 11:20pm UTC](https://discuss.elastic.co/t/java-client-batch-api-missing-invocation-of-afterbulk/40115/5 "2017-07-05T23:20:50Z")

</div>


