Java Reference
In-Depth Information
Synchronously : A subscriber or a receiver explicitly fetches the message from
the destination by calling the receive() method of any MessageConsumer
instance. The receive() method can block until a message arrives or can take
a time out if a message does not arrive within a specified time limit.
Asynchronously : With the asynchronous mode, the client must implement the
javax.jms.MessageListener interface and overwrite the onMessage()
method. Whenever a message arrives at the destination, the JMS provider delivers
the message by calling the listener's onMessage method, which acts on the con-
tents of the message.
A JMS message consists of a header, properties, and a body. The message headers provide
a fixed set of metadata fields that describe the message with information such as where
the message is going and when it is received. The properties are a set of key-value pairs
used for application-specific purposes, usually to help filter messages quickly when they
are received. Finally, the body contains whatever data is being sent to the message.
The JMS API supports two delivery modes for messages to specify whether or not the
messages are lost if the JMS provider fails, indicated by the following constants:
• The persistent delivery mode, which is the default, instructs the JMS provider to
take extra care to ensure that a message is not lost in transit in the case of a JMS
provider failure. A message sent with this delivery mode is logged to stable stor-
age when it is sent.
• The nonpersistent delivery mode does not require the JMS provider to store the
message or otherwise guarantee that it is not lost if the provider fails.
Search WWH ::




Custom Search