This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Does access to a messaging queue need synchronization  RSS feed

 
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is seemingly an elementary question.
If we create a MQ or JMS queue connection - does it need synchronization for multiple threads to be able to send message to it?

MQEnvironment.hostname = hostname;
MQEnvironment.channel = channel;
MQEnvironment.port = portNumber;
qMgr = new MQQueueManager(qManager);
openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
Queue = qMgr.accessQueue(outQueue,openOptions, null, null, null);

Can this 'Queue' handle be passed over to multiple threads to send over messages without synchronization?
If not, why?

Answers with proper justifications will be really appreciated.
 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thread safety guarentees, or lack thereof, are usually part of the JavaDoc API documentation of such frameworks. At least that's how it should be.

For instance, if you browse the API documentation for the IBM MQ classes for Java you'll find:


An MQQueueManager object (and any queues or processes accessed through it) can be shared between multiple threads, but be aware that access to the WebSphere MQ queue manager itself is synchronized, so that only one thread can communicate with it at any one time.



Similarly for JMS in its API documentation:


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


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!