The Java Messaging Service (JMS) is a standard Java EE API that allows loosely
coupled, asynchronous communication between Java EE components. Applications
taking advantage of JMS do not interact directly with each other, instead JMS
message producers send messages to a destination (JMS Queue or Topic), and JMS
consumers receive messages from the said destinations.
There are two messaging domains that can be used when working with JMS, the
Point To Point (PTP) messaging, in which a JMS message is processed by only one
message receiver, and Publish/Subscribe (pub/sub) messaging, in which all message
receivers subscribed to a specific topic receive and process each message for said
topic. JMS applications using the PTP messaging domain use message queues as
their JMS destinations, where applications using pub/sub use message topics.
The following diagram illustrates the JMS architecture:
When working with JMS we need to obtain a reference to a connection factory, either
via JNDI or via dependency injection. From this connection factory we can create a
JMS session, that in turn can be used to create JMS messages.
When developing code to send messages to a JMS destination, we need to create a
JMS message producer from the JMS session. In turn, we use this message producer
to send messages to the destination.
When developing code to receive messages from a JMS destination, we need to
create a message consumer from the JMS session. We can then use this message
consumer to retrieve messages from our JMS destination.
Хоп Г., Вульф Б. - Шаблоны интеграции корпоративных приложений [2007, DjVu, RUS]