# bulkProcessor never calls afterBulk?

**URL:** <https://discuss.elastic.co/t/bulkprocessor-never-calls-afterbulk/23479>\
**Category:** Elasticsearch\
**Created:** [April 29, 2015, 10:30pm UTC](https://discuss.elastic.co/t/bulkprocessor-never-calls-afterbulk/23479 "2015-04-29T22:30:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scott\_Chapman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/scott_chapman/32/108983_2.png) [@Scott\_Chapman](https://discuss.elastic.co/u/Scott_Chapman)\
**Post date:** [April 29, 2015, 10:30pm UTC](https://discuss.elastic.co/t/bulkprocessor-never-calls-afterbulk/23479/1 "2015-04-29T22:30:59Z")

</div>

Here's my code example, I get something printed beforeBulk. But never see  
anything printed for afterBulk. And yes, a document is getting written.

What am I missing??

BulkProcessor bulkProcessor = ((org.elasticsearch.action.bulk.BulkProcessor)  
BulkProcessor).builder(  
client,  
new BulkProcessor.Listener() {  
@Override  
public void beforeBulk(long executionId, BulkRequest request) { System.out.  
println("BeforeBulk"); }

@Override  
public void afterBulk(long executionId, BulkRequest request, Throwable  
failure) {  
System.out.println("Bulk execution failed ["+ executionId + "].\n" +  
failure.toString());  
}

@Override  
public void afterBulk(long executionId, BulkRequest request, BulkResponse  
response) {  
System.out.println("Bulk execution completed ["+ executionId + "].\n" +  
"Took (ms): " + response.getTookInMillis() + "\n" +  
"Failures: " + response.hasFailures() + "\n" +  
"Count: " + response.getItems().length);  
}  
})  
.setBulkActions(10000)  
.setBulkSize(new ByteSizeValue(1, ByteSizeUnit.GB))  
.setFlushInterval(TimeValue.timeValueSeconds(5))  
.setConcurrentRequests(1)  
.build();

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/5ed933f3-ffe4-4ef4-ba87-1f3ef522aaa4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5ed933f3-ffe4-4ef4-ba87-1f3ef522aaa4%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [April 30, 2015, 5:02am UTC](https://discuss.elastic.co/t/bulkprocessor-never-calls-afterbulk/23479/2 "2015-04-30T05:02:24Z")

</div>

Try to remove setBulkSize.  
What is the other part of your code?

David

> Le 30 avr. 2015 à 00:30, Scott Chapman [scottedchapman@gmail.com](mailto:scottedchapman@gmail.com) a écrit :
> 
> Here's my code example, I get something printed beforeBulk. But never see anything printed for afterBulk. And yes, a document is getting written.
> 
> What am I missing??
> 
> BulkProcessor bulkProcessor = ((org.elasticsearch.action.bulk.BulkProcessor) BulkProcessor).builder(  
> client,  
> new BulkProcessor.Listener() {  
> @Override  
> public void beforeBulk(long executionId, BulkRequest request) { System.out.println("BeforeBulk"); }
> 
> @Override  
> public void afterBulk(long executionId, BulkRequest request, Throwable failure) {  
> System.out.println("Bulk execution failed ["+ executionId + "].\n" +  
> failure.toString());  
> }
> 
> @Override  
> public void afterBulk(long executionId, BulkRequest request, BulkResponse response) {  
> System.out.println("Bulk execution completed ["+ executionId + "].\n" +  
> "Took (ms): " + response.getTookInMillis() + "\n" +  
> "Failures: " + response.hasFailures() + "\n" +  
> "Count: " + response.getItems().length);  
> }  
> })  
> .setBulkActions(10000)  
> .setBulkSize(new ByteSizeValue(1, ByteSizeUnit.GB))  
> .setFlushInterval(TimeValue.timeValueSeconds(5))  
> .setConcurrentRequests(1)  
> .build();
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/5ed933f3-ffe4-4ef4-ba87-1f3ef522aaa4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5ed933f3-ffe4-4ef4-ba87-1f3ef522aaa4%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/C2258558-7AD5-40FA-A11F-8570A59C5FAF%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/C2258558-7AD5-40FA-A11F-8570A59C5FAF%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:16am UTC](https://discuss.elastic.co/t/bulkprocessor-never-calls-afterbulk/23479/3 "2017-07-06T00:16:50Z")

</div>


