Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JMS: queueConnection versus QueueSession  RSS feed

 
Sol Mayer-Orn
Ranch Hand
Posts: 311
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
A newbie question:
I see that working with JMS requires the programmer to obtain both a QueueConnection and a QueueSession.
The session idea (in this context) is rather new to me. Comparing it, say, to JDBC : with JDBC programmers only needs to obtain a connection (preferrable a pooled one); there are no sessions.
So, could anyone please shed light on JMS sessions ?
In particular:

1) Are sessions expensive to create (Assuming one has already obtained a connection) ? Do they map to any native resources ?

2) suppose I have a web application, expecting a serious load of users simultaniously.
- All users connect to the same queue.
- The app server and the JMS server are powerful machines (with good software - WAS & MQ in my case).
Would you recommend opening a different connection per user (relying of course on pooling) ?
Or is it enough to have a single connection, and just have a *session* per user ? (I understand both will *work*, but which is more *efficient* ? Again, comparing with JDBC: if it were JDBC i'd go with connection per user, since this allows concurrency, and is also important for transactions).

Thank you very much
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A session is a single-threaded context for producing and consuming messages.
Sessions are not expensive to create.

The javax.jms.connection java doc says that a single connection would suffice for an application.

Most clients will do all their messaging with a single connection. Other more advanced applications may use several connections.JMS API does not architect a reason for using multiple connections; however, there may be operational reasons for doing so.


I would use a single connection.
 
Sol Mayer-Orn
Ranch Hand
Posts: 311
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!