Java Reference
In-Depth Information
Pub/sub messaging has the following characteristics.
• Each message can have multiple consumers.
• Publishers and subscribers have a timing dependency. A client that subscribes to
a topic can consume only messages published after the client has created a sub-
scription, and the subscriber must continue to be active in order for it to consume
messages.
The JMS API relaxes this timing dependency to some extent by allowing subscribers to
create durable subscriptions , which receive messages sent while the subscribers are not
active. Durable subscriptions provide the flexibility and reliability of queues but still al-
low clients to send messages to many recipients. For more information about durable sub-
scriptions, see “ Creating Durable Subscriptions ” on page 364 .
Use pub/sub messaging when each message can be processed by any number of con-
sumers (or none). Figure 20-4 illustrates pub/sub messaging.
FIGURE 20-4. Publish/Subscribe Messaging
Programming with the Common Interfaces
Version 1.1 of the JMS API allows you to use the same code to send and receive messages
under either the PTP or the pub/sub domain. The destinations you use remain domain-spe-
cific, and the behavior of the application will depend in part on whether you are using a
queue or a topic. However, the code itself can be common to both domains, making your
applications flexible and reusable. This tutorial describes and illustrates these common in-
terfaces.
Message Consumption
Messaging products are inherently asynchronous: There is no fundamental timing depend-
ency between the production and the consumption of a message. However, the JMS spe-
Search WWH ::




Custom Search