Chapter 1. Messaging Concepts 1.1. Messaging Systems Messaging systems allow you to loosely couple heterogeneous systems together with added reliability. Unlike systems based on a Remote Procedure Call (RPC) pattern, messaging systems primarily use an asynchronous message passing pattern with no tight relationship between requests and responses. Most messaging systems are flexible enough to also support a request-response mode if needed, but this is not a primary feature of messaging systems. Messaging systems decouple a message's sender of messages from its consumers. In fact, the senders and consumers of messages are completely independent and know nothing of each other, which allows you to create flexible, loosely coupled systems. Large enterprises often use a messaging system to implement a message bus which loosely couples heterogeneous systems together. Message buses can form the core of an Enterprise Service Bus (ESB). Using a message bus to decouple disparate systems allows the system to grow and adapt more easily. It also allows more flexibility to add new systems or retire old ones since they do not have brittle dependencies on each other. Messaging systems can also incorporate concepts such as delivery guarantees to ensure reliable messaging, transactions to aggregate the sending or consuming of multiple message as a single unit of work, and durability to allow messages to survive server failure or restart. 1.2. Messaging Styles There are two kinds of messaging styles that most messaging systems support: the point-to-point pattern and the publish-subscribe pattern. Point-to-Point Pattern The point-to-point pattern involves sending a message to a single consumer listening on a queue. Once in the queue, the message is usually made persistent to guarantee delivery. Once the message has moved through the queue, the messaging system delivers it to a consumer. The consumer acknowledges the delivery of the message once it is processed. There can be multiple consumers listening on the same queue for the same message, but only one consumer will receive each message. Publish-Subscribe Pattern The publish-subscribe pattern allow senders to send messages to multiple consumers using a single destination. This destination is often known as a topic . Each topic can have multiple consumers, or subscribers, and unlike point-to-point messaging, every subscriber receives any message published to the topic. Another interesting distinction is that subscribers can be durable. Durable subscriptions pass the server a unique identifier when connecting, which allows the server to identify and send any messages published to the topic since the last time the subscriber made a connection. Such messages are typically retained by the server even after a restart. 1.3. Jakarta Messaging Jakarta Messaging 2.0 is defined in Jakarta Messaging . Jakarta Messaging is a Java API that provides both point-to-point and publish-subscriber messaging styles. Jakarta Messaging also incorporates the use of transactions. Jakarta Messaging does not define a standard wire format so while vendors of Jakarta Messaging providers may all use the standard APIs, they may use different internal wire protocols to communicate between their clients and servers. 1.4. Jakarta Messaging Destinations Jakarta Messaging destinations, along with Jakarta Messaging connection factories, are administrative objects. Destinations are used by Jakarta Messaging clients for both producing and consuming messages. The destination allows clients to specify the target when it produces messages and the source of messages when consuming messages. When using a publish-subscribe pattern, destinations are referred to as topics. When using a point-to-point pattern, destinations are referred to as queues. Applications may use many different Jakarta Messaging destinations which are configured on the server side and usually accessed via JNDI.

Commands: