Should a JMS application create a new session for every message that it sends or is it preferable to create a session for a long message sequence?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I would say no in general, though it really depends on the context and on how you logically think of communications in your application.
If message sending is an occasional one-off thing, and subsequent messages are completely unrelated, then yes if you can tolerate the costs.
If you do have a lengthy and logical sequence of interaction, it makes sense to do them within a session as long as you don’t mess up your threading.
A session actually provides facilities for a sequence of messages, so by definition it is meant to deal with multiple messages.
Here is what the docs say: