Volume: 6
Issue: 4
Guaranteed
Messaging With JMS, by David Chappell & Richard
Monson-Haefel
Listing 1
public void onMessage(javax.jms.Message message){
int count = 1000;
try{
// perform some business logic with the message
...
message.acknowledge();
// perform more business logic with the message
...
}catch (javax.jms.JMSException jmse){
// catch the exception thrown and undo the results
// of partial processing
...
}
}
Listing2
// pub/sub connection creates a transacted TopicSession
javax.jms.TopicSession session =connect.createTopicSession(true,Session.AUTO_ACKNOWLEDGE);
// p2p connection creates a transacted QueueSession
javax.jms.QueueSession =
connect.createQueueSession(true,Session.AUTO_ACKNOWLEDGE);
...
}