This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes JMS Queue and Topic Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JMS Queue and Topic" Watch "JMS Queue and Topic" New topic
Author

JMS Queue and Topic

Natalie Kopple
Ranch Hand

Joined: May 06, 2003
Posts: 325
Would someone help me to understand when we would use queue versus topic and vice versa? and why would someone use a queue with multiple consumers? Thank you.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30050
    
149

In a queue, only one destination gets the message and in a topic all subscribers get it. A queue with multiple consumers could be used for redundancy.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Natalie Kopple
Ranch Hand

Joined: May 06, 2003
Posts: 325
Thanks Jeanne for your help. I did some homework and also would like to answer my own question.

Using a queue with multiple consumers usually makes sense when different consumers are responsible for processing messages containing the same headers (often generated by the same producer) written onto the same queue. For instance, message selectors could be used in a trading application, to differentiate between buy and sell orders, when the producer is incapable of writing the JMS messages onto two separate buy and sell queues.

When multiple consumers use the same queue, message selectors need to be configured correctly across these consumers so that there is no conflict in determining the intended consumer.

In the case of message-driven-beans (a consumer of JMS messages), the selector can be specified in the ejb-jar.xml file thereby allowing for the configuration to be done at deployment time (instead of the opposing view of specifying the message selector during development).
 
 
subject: JMS Queue and Topic
 
Similar Threads
JBoss crash handling
General question about JMS system structure
JBOSS AND JMS HELP!!!
JMS : USING JMS ReplyTo Queue
message selector