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.

Était-ce utile?

La 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.

Autres conseils

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);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top