Hello,
i need to be able to retrivet the JMSMessageID of a message i am sending in order to be able to retrive and answer later on.
Fetching the id inside the JmsTemplate.send() method does not seem to work. probably because the message has not actually been sent at the time.
This sends the message ok, but does not have an message id yet:
jmsTemplate102.send(new MessageCreator() {
public Message createMessage(Session session) throws JMSException {
BytesMessage message=session.createBytesMessage();
message.writeBytes(data.toString().getBytes());
system.out.println(message.getJMSMessageID(); //This prints null
return message;
Then i thought i would use the JmsTemplate102.execute(ProducerCallback) method, but when i do this:
jmsTemplate102.execute(new ProducerCallback() {
public Object doInJms(Session session, MessageProducer producer) throws JMSException {
BytesMessage message =session.createBytesMessage();
message.writeBytes("...".getBytes());
((QueueSender)producer).send(message);
System.out.println("message id " + message.getJMSMessageId());
return null;
}
});
I get an exception from the JMS provider the the queue is unknown.
I then find that the QueueSender.getQueue() returns null. ie. the Queue is not defined for the MessageProducer.
Please note that i can send perfectly well using the JmsTemplate102.send() method.
Can someone help me get this to work, or suggest an alternative solution.
sincerely
Morten


Reply With Quote