Java Reference
In-Depth Information
Handling of the JMSXDeliveryCount message property
Since Version 1.1, the JMS Specification has defined an optional JMSXDeliv-
eryCount message property, which can be used to determine the messages that
were delivered more than once and apply an action when the number of deliveries
exceeds the maximum value. But, because the management of this property was op-
tional, all providers had no obligation to increment it, which had the effect of making
applications that used it non portable. The JMS 2.0 Specification has introduced this
as standard, to allow us to customize the management of poisonous messages
in a portable way. A poisonous message is a JMS message that has exceeded the
maximum number of deliveries for a given receiver. The following code shows how
to retrieve the JMSXDeliveryCount message property and specify the action to be
taken when one message has been delivered more that five time:
public class JmsMessageListener implements
MessageListener {
@Override
public void onMessage(Message message) {
try {
int jmsxDeliveryCount
=message.getIntProperty("JMSXDeliveryCount");
//...
if(jmsxDeliveryCount > 5){
// do something
}
} catch (JMSException ex) {
ex.printStackTrace();
}
}
}
Simplification of the API
The JMS 2.0 Specification introduces three new interfaces ( JMSContext , JMSPro-
ducer , and JMSConsumer ) which contribute to the elimination of boilerplate code
and simplifying the API. It is important to note that these interfaces (which constitute
the simplified API) co-exist with the old interfaces to provide an alternative. So
Search WWH ::




Custom Search