PDA

View Full Version : Using JMS Transacted Session with JmsTemplate



donalstar
Mar 11th, 2005, 02:42 PM
Hello,

I've been trying to use the JmsTemplate to do the following:

* Create a transacted JMS session
* Consume messages from a JMS Queue
* Commit/rollback the session at some later stage

This does not work for me.

I'm creating my JMS session & getting the queued messages okay:

template = new JmsTemplate102();
template.setConnectionFactory(connectionFactory);

template.setReceiveTimeout(100);
template.setSessionTransacted(true);
template.setDestinationResolver( new JndiDestinationResolver() );

...
Message nextMessage =
template.receiveSelected(selector);
... etc

& then I try to commit/rollback the session using the JmsTemplate.SessionCallback

At first glance, it looks like JmsTemplate.doReceive() is *always* committing my session, so my later commit/rollback will not succeed.

Am I misunderstanding something here?

Thanks in advance.

Donal