Java Reference
In-Depth Information
knowledges the receipt of all messages that have been consumed by its session. For
example, if a message consumer consumes ten messages and then acknowledges
the fifth message delivered, all ten messages are acknowledged.
Note
In the Java EE platform, a CLIENT_ACKNOWLEDGE session can be
used only in an application client, not in a web component or enterprise
bean.
Session.DUPS_OK_ACKNOWLEDGE : This option instructs the session to lazily
acknowledge the delivery of messages. This is likely to result in the delivery of
some duplicate messages if the JMS provider fails, so it should be used only by
consumers that can tolerate duplicate messages. (If the JMS provider redelivers
a message, it must set the value of the JMSRedelivered message header to
true .) This option can reduce session overhead by minimizing the work the ses-
sion does to prevent duplicates.
If messages have been received from a queue but not acknowledged when a session ter-
minates, the JMS provider retains them and redelivers them when a consumer next ac-
cesses the queue. The provider also retains unacknowledged messages for a terminated
session that has a durable TopicSubscriber . (See “ Creating Durable Subscriptions
on page 364 .) Unacknowledged messages for a nondurable TopicSubscriber are
dropped when the session is closed.
If you use a queue or a durable subscription, you can use the Session.recover meth-
od to stop a nontransacted session and restart it with its first unacknowledged message.
In effect, the session's series of delivered messages is reset to the point after its last ac-
knowledged message. The messages it now delivers may be different from those that were
originally delivered, if messages have expired or if higher-priority messages have arrived.
For a nondurable TopicSubscriber , the provider may drop unacknowledged mes-
sages when its session is recovered.
The sample program in A Message Acknowledgment Example ” on page 406 demon-
strates two ways to ensure that a message will not be acknowledged until processing of
the message is complete.
Specifying Message Persistence
The JMS API supports two delivery modes specifying whether messages are lost if the
JMS provider fails. These delivery modes are fields of the DeliveryMode interface.
Search WWH ::




Custom Search