On Fri, 2009-05-01 at 06:44 -0700, nmittal wrote: > below is an excerpt from the book "ActiveMQ in action"... > The JMS spec specifically defines concurrency for various objects in the JMS > API and requires that only a few objects support concurrent access. The > ConnectionFactory, Connection and Destination objects are required to > support concurrent access while the Session, the MessageProducer and the > MessageConsumer objects do not support concurrent access. The point is that > the Session, the MessageProducer and the MessageConsumer objects should not > be shared across threads in a Java application. > > However, the the examples that come with ActiveMQ CPP... the onMessage > function uses the session, consumer objects. I think the onMessage would be > called in seperate threads for each message in the queue. So given that > session and consumer classes are not threadsafe...is it correct to do so? > > thanks > Nishant >
While the spec defines that certain types be thread safe we've shrived to ensure that all operations on the CMS objects are thread safe. That being said I would advise showing constraint on overusing CMS objects in a method like onMessage as the time spent in that method delays delivery of messages, so you wouldn't want to start producing messages from onMessage for instance. Regards Tim. -- Tim Bish http://fusesource.com http://timbish.blogspot.com/