Yes, the client object is closed each time. The bulk indexing service calls the service which, let's say, indexes all the orders from the database. So, a service is called *asynchronously* from within the bulk service which indexes order related data individually for each order. There may be more than one such bulk services.
Pseudo code: createOrdersIndex () { allThe Orders.iterate { createOrderIndex(orderId) } } createOrderIndex() { get the client object client.add(SolrInputDocument) client.close() } The individual service indexing each order is scheduled, each one having a client object. So there is a possibility that the services have not yet finished execution, meaning the client objects are not closed yet, resulting in connection timeout. This is how I have prepared the CloudSolrClient object client = new CloudSolrClient.Builder().withZkHost("zkHosts").build(); client.setDefaultCollection(collectionName) Hope, this gives a clear picture of the problem I am facing. On Mon, Jul 2, 2018 at 7:41 PM Erick Erickson <erickerick...@gmail.com> wrote: > It's recommended to use one object of course. That said, you should > not be having a connection problem just because you create new ones > all the time. Are you closing it after you're done with it each time? > > As to your question about how to reuse the same one, the "singleton > pattern" is one solution. > > Best, > Erick > > On Mon, Jul 2, 2018 at 6:35 AM, Ritesh Kumar > <ritesh.ku...@hotwaxsystems.com> wrote: > > Hello Team, > > > > I have got a static method which returns CloudSolrClient object if Solr > is > > running in Cloud mode and HttpSolrClient object otherwise. > > > > When running bulk indexing service, this method is called from within the > > indexing service to get the appropriate client object. Each time, this > > method creates a new client object. The problem is, when the bulk > indexing > > service is run, after a while, connection error occurs (could not connect > > to zookeeper running at 0.0.0.0:2181. It seems the Zookeeper runs out of > > connections. > > > > Configuration: > > One Zookeeper - maxClientCnxns=60 > > Two Solr nodes, running in the Cloud mode. > > > > After looking out for the solution, I could find that CloudSolrClient is > > thread safe provided it collection remains the same. > > > > How can I create an object of CloudSolrClient such that it is used > > throughout the application without creating a new object each time the > data > > is indexed. > > > > Best, > > Ritesh Kumar >