Re: Creating single CloudSolrClient object which can be used throughout the application

2018-07-05 Thread Erick Erickson
Just a try block or a try-with-resources block? I.e. try (CloudSolrClient csc = new ClousSolrClient.) { } try-with-resources is _designed_ to call close when the block is exited, there's no mystery involved at all. Best, Erick On Wed, Jul 4, 2018 at 10:13 PM, Ritesh Kumar wrote: > Hello Sh

Re: Creating single CloudSolrClient object which can be used throughout the application

2018-07-04 Thread Ritesh Kumar
Hello Shawn, I wasn't explicitly closing the client object but I fetched the client object inside the try block and this seems to automatically destroy the client object. Taking it out of the try block worked like magic. Problem solved! Best On Wed, Jul 4, 2018 at 10:40 PM Shawn Heisey wrote:

Re: Creating single CloudSolrClient object which can be used throughout the application

2018-07-04 Thread Shawn Heisey
On 7/4/2018 2:41 AM, Ritesh Kumar wrote: I did exactly as you told, created a public static synchronized method. The problem still exists. I wasn't addressing the connection problem.  I was addressing the question in the subject -- one client object that you can use everywhere.  But I think t

Re: Creating single CloudSolrClient object which can be used throughout the application

2018-07-04 Thread Ritesh Kumar
Hello Shawn, I did exactly as you told, created a public static synchronized method. The problem still exists. Maybe returning the client object if it is not null is causing " java.lang.IllegalStateException: Connection pool shut down" error. It does run fine for just one time. pseudo code: priv

Re: Creating single CloudSolrClient object which can be used throughout the application

2018-07-02 Thread Shawn Heisey
On 7/2/2018 7:35 AM, Ritesh Kumar wrote: > I have got a static method which returns CloudSolrClient object if Solr is > running in Cloud mode and HttpSolrClient object otherwise. Declare that method as synchronized, so that multiple usages do not step on each other's toes.  This will also eliminat

Re: Creating single CloudSolrClient object which can be used throughout the application

2018-07-02 Thread Ritesh Kumar
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

Re: Creating single CloudSolrClient object which can be used throughout the application

2018-07-02 Thread Erick Erickson
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

Creating single CloudSolrClient object which can be used throughout the application

2018-07-02 Thread Ritesh Kumar
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