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

Reply via email to