Hey Spring Team first just want to say Spring really ROCKS!
I am working on it with my first project and it really makes wiring up an application & testing easy...

But now a question (potential enhancement) for JmsTemplate.
Scenario:
I have an application that uses JMS to manage a message as it is processed by various agents. An agent within the application needs to read a message off Q1, do some processing, write the message to Q2, then acknowledge the message from Q1.

While I know that the resources for the JMS session are locked until the ack is sent (and the time here is dependent on the processing we do) this application needs to make sure that messages are not lost as they move from one Q to another. If the system were to have any issues/crash during processing we would lose the message since it was not on any of the Qs.

JmsTemplate:
I started looking at using Spring's JmsTemplate to handle our JMS needs. I noticed however that this class does not provide any public methods to acknowledge (or commit/rollback) a message even though the user of the class can call setSessionTransacted or setSessionAcknowledgeMode.

When I looked at the source code for JmsTemplate I noticed that the variable used by setSessionAcknowledgeMode (sessionAcknowledgeMode) is not used to determine when or if to call the Message.acknowledge method. Instead the doReceive method of JmsTemplate calls the Message.acknowledge after a successful consumer.receive() call.

In our scenario above the message would be acknowledged off Q1 before being processed or written to Q2 (even when setting CLIENT_ACKNOWLEDGE) and would leave the potential of losing the message in our given scenario.

I think that this topic in the Spring forums started to address this problem, seems that sessionAcknowledgeMode was going to be checked and the call to Message.acknowledge() was going to be called when set to CLIENT_ACKNOWLEDGE to bypass a problem calling acknowledge when setting mode to AUTO_ACKNOWLEDGE in WebSphereMQ.
http://forum.springframework.org/vie...ht=acknowledge

However I think that if sessionAcknowledgeMode is set to CLIENT_ACKNOWLEDGE then the JmsTemplate should not call message.acknowledge at all but provide the capability of the user of JmsTemplate to call a public method that does this.

What do you think?

Thanks,
Mike