views:

199

answers:

1

Dear all,

I am new to JMS API , I want to try QueueSender in multi-thread environment.... So, the question .. Is QueueSender.send() thread safe ?please provide reference or demo if available

thanks in advance,,,,

+4  A: 

No, a MessageProducer/QueueSender is not thread safe.

Or more specifically: The Session is not thread safe. The JavaDoc for Session explicitly mentions ths in its first sentence:

A Session object is a single-threaded context for producing and consuming messages.

And since a MessageProducer/QueueSender is bound to a Session you 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!

Joachim Sauer
Many thanks for fast your reply
worldpython