Question

Anyone can explain the real purpose of JMSTemplate.execute method. It can accept a session callback. The Spring document does not say any details about it.

Was it helpful?

Solution

The Spring documentation is pretty specific about its JMS capabilities, and it ends with a brief description of JmsTemplate.execute(). That coupled with the javadoc for JmsTemplate.execute() and the SessionCallback should give you a pretty clear idea of what it does.

OTHER TIPS

You can use it to get hold of a raw JMS Session and do something with this session object. For eg, you can use it to get a QueueBrowser to peek at the contents of the queue without actually consuming the messages.

execute(new SessionCallback<QueueBrowser>() {
        public QueueBrowser doInJms(Session session) throws JMSException {
            return session.createBrowser(queue);
        }
    }, true);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top