TransportClient ElasticSearch 6.0

I use TransportClient in order to connect with ES but the operation was too slow. In order to see what's going on, I measure time. The response from ES was 1ms which is fine but the client.close() operation was too slow.

What maybe happen? Am I doing something wrong?

Thank you in advance!

WHy do you want to close the client?

Because as my app run I will create many clients which will be open if I don't close them.

Just create one instance that you share.
It's Threadsafe.

How can I do this? May I have to change elasticsearch.yml?

How do you create the client?

I make a new TransportClient every time I want to use ES

TransportClient client=new PreBuiltTransportClient(Settings.EMPTY)
            .addTransportAddress(new TransportAddress(InetAddress.getByName(grailsApplication.config.elasticsearch.server.host),grailsApplication.config.elasticsearch.server.port.toInteger()))

Use a Singleton instead that you will reuse anytime you need.

Thank you very much!!!

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