Java Reference
In-Depth Information
cification uses this term in a more precise sense. Messages can be consumed in either of
two ways:
•
Synchronously
: A subscriber or a receiver explicitly fetches the message from the
destination by calling the
receive
method. The
receive
method can block un-
til a message arrives or can time out if a message does not arrive within a specified
time limit.
•
Asynchronously
: A client can register a
message listener
with a consumer. A mes-
sage listener is similar to an event listener. Whenever a message arrives at the des-
tination, the JMS provider delivers the message by calling the listener's
onMes-
sage
method, which acts on the contents of the message.
The JMS API Programming Model
The basic building blocks of a JMS application are:
• Administered objects: connection factories and destinations
• Connections
• Sessions
• Message producers
• Message consumers
• Messages
Figure 20-5
shows how all these objects fit together in a JMS client application.