Java High Rest Client, how to call CLOSE() waiting for ASYNC request


(Michael Sogos) #1

Dear,

How is it possible to wait for ASYNC REQUEST complete before call Close()?

We are using Java High Rest Client.

Our target is to create one instance of RestHighLevelClient, make many ASYNC requests (using indexAsync() method) and close the client.

Actually our issue is that we send many ASYNC request from inside a ForEach and at the end of the ForEach we call the Close() method of the client. Unfortunately it is so fast that no documents will be saved in Elastic index because we call the Close() methods before the requests has been sent to Elastic.

How we should manage this properly?


(David Pilato) #2

Why not using the bulk processor instead?

That'd be much more efficient IMO.


(Michael Sogos) #3

Great Idea!

I will try :slight_smile:


(system) #4

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