Concurrency

Is JMS Connection thread-safe?

Yes, connection object is completely thread safe. In an application, you can use the same connection to cater to multiple publishing and subscription (using multiple sessions from a connection).


If anyways we are creating multiple sessions from a connection, what is the need to create multiple connections in an application? Should not just One connection suffice?

Yes, One connection can suffice. But, one connection means one Physical sockets connection. One may want to use a few multiple connections so that there is not much load on one connection (or socket)


Ok, that sound good. But how many connections and how many sessions per connection should one application use? And How an application should do the connection pooling?

Good question. I do not have answer for this currently. A Hint can be taken from this link:

http://www-01.ibm.com/support/docview.wss?uid=swg21168924


We can have connection Pool, which makes sense. Should we have session pool also?

Session pool does not make sense to me, since session should be created for one thread. Once used, it should be closed. (will confirm this)