Example usage for org.springframework.jms.core ProducerCallback doInJms

List of usage examples for org.springframework.jms.core ProducerCallback doInJms

Introduction

In this page you can find the example usage for org.springframework.jms.core ProducerCallback doInJms.

Prototype

@Nullable
T doInJms(Session session, MessageProducer producer) throws JMSException;

Source Link

Document

Perform operations on the given Session and MessageProducer .

Usage

From source file:com.ccc.ccm.client.JMSTemplateAutowired.java

public <T> T execute(final Destination destination, final ProducerCallback<T> action) throws JmsException {
    Assert.notNull(action, "Callback object must not be null");
    return execute(new SessionCallback<T>() {
        public T doInJms(Session session) throws JMSException {
            MessageProducer producer = createProducer(session, destination);
            try {
                return action.doInJms(session, producer);
            } finally {
                JmsUtils.closeMessageProducer(producer);
            }/* w w w .  j  a v  a2  s . c om*/
        }
    }, false);
}

From source file:com.ccc.ccm.client.JMSTemplateAutowired.java

public <T> T execute(final String destinationName, final ProducerCallback<T> action) throws JmsException {
    Assert.notNull(action, "Callback object must not be null");
    return execute(new SessionCallback<T>() {
        public T doInJms(Session session) throws JMSException {
            Destination destination = resolveDestinationName(session, destinationName);
            MessageProducer producer = createProducer(session, destination);
            try {
                return action.doInJms(session, producer);
            } finally {
                JmsUtils.closeMessageProducer(producer);
            }// ww w . ja  v  a  2 s  .  c om
        }
    }, false);
}

From source file:org.springframework.jms.core.JmsTemplate.java

public Object execute(final ProducerCallback action) throws JmsException {
    return execute(new SessionCallback() {
        public Object doInJms(Session session) throws JMSException {
            MessageProducer producer = createProducer(session, null);
            return action.doInJms(session, producer);
        }/*from   w w w  . java 2 s  .co m*/
    });
}