background image

Using Basic Reliability Mechanisms

<< Deleting the Connection Factory | Nontransacted Sessions >>
<< Deleting the Connection Factory | Nontransacted Sessions >>

Using Basic Reliability Mechanisms

For other applications, a lower level of reliability can reduce overhead and improve
performance. You can send messages with varying priority levels (see
"Setting Message Priority
Levels" on page 941
) and you can set them to expire after a certain length of time (see
"Allowing
Messages to Expire" on page 941
).
The JMS API provides several ways to achieve various kinds and degrees of reliability. This
section divides them into two categories:
"Using Basic Reliability Mechanisms" on page 936
"Using Advanced Reliability Mechanisms" on page 942
The following sections describe these features as they apply to JMS clients. Some of the features
work differently in Java EE applications; in these cases, the differences are noted here and are
explained in detail in
"Using the JMS API in a Java EE Application" on page 954
.
This section includes three sample programs, which you can find in the directory
tut-install/javaeetutorial5/examples/jms/advanced/. Each sample uses a utility class called
SampleUtilities.java
.
Using Basic Reliability Mechanisms
The basic mechanisms for achieving or affecting reliable message delivery are as follows:
Controlling message acknowledgment
: You can specify various levels of control over
message acknowledgment.
Specifying message persistence
: You can specify that messages are persistent, meaning that
they must not be lost in the event of a provider failure.
Setting message priority levels
: You can set various priority levels for messages, which can
affect the order in which the messages are delivered.
Allowing messages to expire
: You can specify an expiration time for messages so that they
will not be delivered if they are obsolete.
Creating temporary destinations
: You can create temporary destinations that last only for
the duration of the connection in which they are created.
Controlling Message Acknowledgment
Until a JMS message has been acknowledged, it is not considered to be successfully consumed.
The successful consumption of a message ordinarily takes place in three stages.
1. The client receives the message.
2. The client processes the message.
3. The message is acknowledged. Acknowledgment is initiated either by the JMS provider or
by the client, depending on the session acknowledgment mode.
Creating Robust JMS Applications
The Java EE 5 Tutorial · September 2007
936