List of usage examples for org.springframework.jms.core MessageCreator createMessage
Message createMessage(Session session) throws JMSException;
From source file:org.calrissian.mango.jms.stream.AbstractJmsFileTransferSupport.java
@SuppressWarnings({ "unchecked", "rawtypes" })
protected Message sendWithResponse(final MessageCreator mc, final Destination replyTo) {
return (Message) jmsTemplate.execute(new SessionCallback() {
@Override/*from w ww. j av a 2 s . co m*/
public Object doInJms(Session session) throws JMSException {
DestinationRequestor requestor = null;
try {
Message sendMessage = mc.createMessage(session);
requestor = new DestinationRequestor(session, replyTo, jmsTemplate.getReceiveTimeout());
Message returnMessage = requestor.request(sendMessage);
requestor.close();
return returnMessage;
} finally {
if (requestor != null)
requestor.close();
}
}
}, true);
}
From source file:com.ccc.ccm.client.JMSTemplateAutowired.java
/** * Send the given JMS message.//w w w. java2 s . com * @param session the JMS Session to operate on * @param destination the JMS Destination to send to * @param messageCreator callback to create a JMS Message * @throws JMSException if thrown by JMS API methods */ protected void doSend(Session session, Destination destination, MessageCreator messageCreator) throws JMSException { Assert.notNull(messageCreator, "MessageCreator must not be null"); MessageProducer producer = createProducer(session, destination); try { Message message = messageCreator.createMessage(session); if (logger.isDebugEnabled()) { logger.debug("Sending created message: " + message); } doSend(producer, message); // Check commit - avoid commit call within a JTA transaction. if (session.getTransacted() && isSessionLocallyTransacted(session)) { // Transacted session created by this template -> commit. JmsUtils.commitIfNecessary(session); } } finally { JmsUtils.closeMessageProducer(producer); } }
From source file:org.springframework.jms.core.JmsTemplate.java
protected void doSend(Session session, Destination destination, MessageCreator messageCreator) throws JMSException { MessageProducer producer = createProducer(session, destination); Message message = messageCreator.createMessage(session); if (logger.isDebugEnabled()) { logger.debug("Sending created message [" + message + "]"); }/*from w w w. java 2 s. c om*/ doSend(producer, message); if (session.getTransacted() && !TransactionSynchronizationManager.hasResource(getConnectionFactory())) { // transacted session created by this template -> commit session.commit(); } }