Section 7.4. JMS Messaging Models


7.4. JMS Messaging Models

JMS has two messaging models Point-to-Point (P2P ) and Publish-Subscribe (Pub-Sub ). P2P is a traditional one-to-one queueing mechanismalthough multiple Consumers can listen on a queue, only one Consumer receives a particular message. Producers send messages to a queue, and the JMS Server delivers each message sequentially to a Consumer listening on the queue. Figure 7-3 shows the relationships between Point-to-Point Producers and Consumers.

Figure 7-3. JMS Point-to-Point (P2P) Messaging model


Publish-Subscribe is a one-to-many broadcast model, similar to a newsgroup or an RSS newsfeed. Producers publish messages to a topic, and the JMS Server delivers messages sequentially to those Consumers subscribed to that topic. Figure 7-4 shows the relationships between Pub-Sub Producers and Consumers.

7.4.1. Choosing a Messaging Model

Most applications that use the Publish-Subscribe model could use Point-to-Point, and vice versa. How do you choose a messaging model? We'll give the standard consultant's answer"It depends." Just like other technologies, your application requirements determine how to use JMS messaging. According to Richard Monson-Haefel (author of the best-selling O'Reilly EJB book and co-author of O'Reilly's JMS book), Point-Point JMS messaging is like sending an email message to a single recipient. Point-to-Point is a way to distribute workload because only one consumer receives a particular message. Publish-Subscribe JMS messaging is like sending/broadcasting an email message to a recipient listmany consumers receive the same message.

Figure 7-4. JMS Publish-Subscribe (Pub-Sub) Messaging model


The JAW Motors application sends a message when a user requests a credit check, and we want only one consumer to process a particular message just once. So in this chapter, we use the Point-to-Point model. The biggest difference between P2P and Pub-Sub is that in the Publish-Subscribe Model, all Consumers that subscribe to a Topic can receive all messages published to that topic, while with Point-to-Point, only one Consumer on a queue receives a particular message.

We've covered the basics of JMS architecture and chosen to use a Queue to hold our message because we selected the Point-to-Point model. Now we need to create a message (that holds the user's credit information) to send to the Queue.



JBoss at Work. A Practical Guide
JBoss at Work: A Practical Guide
ISBN: 0596007345
EAN: 2147483647
Year: 2004
Pages: 197

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net