We have an application that listens on a queue for messages and I know that the dmlc provides a sessionTransacted property that I assume would allow us to manually commit the message receive event, however I am not sure how to leverage it in the Listener.
It seems that simply by throwing a RuntimeException the message gets put back onto the queue and goes into a loop if an ErrorHandler has not been set but we would like to specifically commit the receive.
e.g.
public class JMSMessageListener implements MessageListener {
@Override
public void onMessage(Message message) {
// do something with the message and then manually commit
}
}
A have an experience with ActiveMQ. When sessionTransacted
is enabled, if your application shuts down unexpectedly in onMessage
, the message will be handled again after restart. If session is not transacted, it will be lost.
You cannot manually control transaction (except throwing an exception to roll message back) using sessionTransacted
. You might want to take a look at SessionAwareMessageListener, although I have never tried it.