I am trying to figure out how to use BulkProcessor [Bulk API | Java REST Client [7.14] | Elastic] during synchronous processing (bulk method) so that I could write something like this:
@dadoonet thank you for the response. BulkProcessor allows me to configure backoffpolicy and bulksize. Is it possible to configure mentioned properties using the synchronous bulk method?
I also wonder the same thing, but regardless of the "why" it's always simple to turn an asynchronous call into a synchronous one: simply make the async call and then block until the listener completes. For instance, create a new java.util.concurrent.CountDownLatch(1) and a listener that calls CountDownLatch#countDown() on completion, then pass the listener into the async call and block the calling thread by calling CountDownLatch#await() on it.
@DavidTurner thank you for your answer. Maybe my question was wrong. I would like to set properties like backoffpolicy and bulksize. I know that I can set them using BulkProcessor (hence my question).
If BulkProcessor is designed for async calls then is there any other way to set mentioned properties using sync calls (bulk method)?
The parameters you are asking about are parameters of the bulk processor, so it doesn't really make sense to ask about using them without using the bulk processor. Why not just use the bulk processor (modifying it to work synchronously as I described)? If you don't want that, you'll need to write some code to retry with backoff and to size the bulks according to your needs.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.