I want to use a QueueSender in a multi-threaded environment.
Is QueueSender.send() thread safe?
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.
No, a
MessageProducer/QueueSenderis not thread safe.Or more specifically: The
Sessionis not thread safe. The JavaDoc forSessionexplicitly mentions this in its first sentence:And since a
MessageProducer/QueueSenderis bound to aSessionyou must not use it from more than one thread at the same time. In fact you must not use it from two different threads at different times either!