Hi all,
got the solution. I've found it in the excellent "Professional Java Development with Spring" book:
Code:
public void sendStringWithId(String msg, String correlationId)
{
log.info("Start JMS template method for sending strings");
JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory);
final String textMessage = msg;
final String corrId = correlationId;
log.debug("Text message: " + textMessage);
log.debug("CorrelationId: " + correlationId);
log.debug("Sending string with CorrelationId " + correlationId);
/*
* Callback method for sending JMS message with specific Correlation ID
*/
jmsTemplate.send(sendQueueName, new MessageCreator()
{
public Message createMessage(Session session) throws JMSException
{
Message m = session.createTextMessage(textMessage);
m.setJMSCorrelationID(corrId);
return m;
}
});
}
Pieper