Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Add a blocking variant of close() method to BulkProcessor #4158
Using BulkProcessor I often want to block when calling BulkProcessor.close() until all BulkRequests have completed.
Currently this isn't possible. If you use concurrentRequests > 0, calling close() will execute a new bulk request asynchronously then return immediately.
It's possible to write a wrapper around BulkProcessor to implement this behaviour, but it's a bit tricky as you have to understand the Exception handling quirks of BulkProcessor and be aware that every call to listener.beforeBulk() will not guarantee a corresponding call to listener.afterBulk().
It would be nice to have this behaviour implemented as part of the core library. I suggest using this method name:
boolean awaitClose(long timeout, TimeUnit unit) throws InterruptedException;