Transport Client

Hi Team,

We have a Java web application which works in following manner -

1)Obtain TransportClient instance by supplying cluster, url and port.
2)Execute the query using TransportClient instance in step 1 and get the SearchResponse instance.
3)Process the SearchResponce from step 2.
4)Close the TransportClient in finally block of java program by calling TransportClient.close() method.

From the web app whenever user hit the Search button from GUI we perform the above steps for each Search operation.

I have a question - Is it correct to obtain a TransportClient for each search operation and close it after SearchResponse is processed in finally block? But I have read somewhere that since Transport client is thread safe so we should obtain it in a singleton factory and close it only when we shut the server down (in our case the server is Jboss) or when the application is down.

Kindly advice.

Regards

IMHO, it's best to have a singleton factory and close the TransportClient
only when you shutdown the webapp.

That's what I did in production without issues.

HTH,
David.

Le 26 mars 2012 à 14:11, ElasticUsers kranti_123@rediffmail.com a écrit :

Hi Team,

We have a Java web application which works in following manner -

1)Obtain TransportClient instance by supplying cluster, url and port.
2)Execute the query using TransportClient instance in step 1 and get the
SearchResponse instance.
3)Process the SearchResponce from step 2.
4)Close the TransportClient in finally block of java program by calling
TransportClient.close() method.

From the web app whenever user hit the Search button from GUI we perform
the
above steps for each Search operation.

I have a question - Is it correct to obtain a TransportClient for each
search operation and close it after SearchResponse is processed in
finally
block? But I have read somewhere that since Transport client is thread
safe
so we should obtain it in a singleton factory and close it only when we
shut
the server down (in our case the server is Jboss) or when the application
is
down.

Kindly advice.

Regards

--
View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/Transport-Client-tp3857974p3857974.html
Sent from the Elasticsearch Users mailing list archive at Nabble.com.

--
David Pilato
http://dev.david.pilato.fr/
Twitter : @dadoonet

Yes, keep the TransportClient instance around, and reuse it.

On Mon, Mar 26, 2012 at 2:30 PM, david@pilato.fr david@pilato.fr wrote:

**

IMHO, it's best to have a singleton factory and close the TransportClient
only when you shutdown the webapp.

That's what I did in production without issues.

HTH,

David.

Le 26 mars 2012 à 14:11, ElasticUsers kranti_123@rediffmail.com a
écrit :

Hi Team,

We have a Java web application which works in following manner -

1)Obtain TransportClient instance by supplying cluster, url and port.
2)Execute the query using TransportClient instance in step 1 and get the
SearchResponse instance.
3)Process the SearchResponce from step 2.
4)Close the TransportClient in finally block of java program by calling
TransportClient.close() method.

From the web app whenever user hit the Search button from GUI we perform
the
above steps for each Search operation.

I have a question - Is it correct to obtain a TransportClient for each
search operation and close it after SearchResponse is processed in
finally
block? But I have read somewhere that since Transport client is thread
safe
so we should obtain it in a singleton factory and close it only when we
shut
the server down (in our case the server is Jboss) or when the
application is
down.

Kindly advice.

Regards

--
View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/Transport-Client-tp3857974p3857974.html
Sent from the Elasticsearch Users mailing list archive at Nabble.com.

--
David Pilato
http://dev.david.pilato.fr/
Twitter : @dadoonet

Thanks..