Reputation: 2207
I am sending a JMS message with the outbound channel adapter like this:
<intjms:outbound-channel-adapter
destination-name="MY.QUEUE"
connection-factory="myConnectionFactory"
channel="mySender"/>
After this I need to know the JMS Message Id. How can I get it?
There is a way to do it in a custom JmsTemplate
I could provide in the adapter, but maybe there is a simpler solution for this problem.
I can not use the gateway because there is no response.
Upvotes: 1
Views: 1318
Reputation: 121580
You can send JMS Message
as a payload
of Spring Integration Message to that adapter. And use its getJMSMessageID()
after successful sending.
UPDATE
But this means I can not use the convencience of the JmsTemplate and have to deal with javax.jms.Connection and javax.jms.Session on my own to be able to create a javax.jms.Message, correct?
Well, no one forbid you to use even JmsTemplate
directly as a reference from the general <service-activator>
. The <outbound-channel-adapter>
is one-way by the goal. So it is really not intended to return anything. Your corner case really requires something to do. And that is the javax.jms.Session
hooks and tricks to create a JMS Message to be able to retrieve its ID
afterwards. There is a ThreadLocal
hole over the custom JmsHeaderMapper
and the message access from its fromHeaders()
implementation, but I think that for this case it would be better to use JmsTemplate
directly.
Upvotes: 1