Announcement Announcement Module
No announcement yet.
How does one set a JMSReplyTo on an SI Message? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How does one set a JMSReplyTo on an SI Message?


    I would like to use SpringIntegration (SI) to send a StringMessage on an SI channel which then gets placed onto a JMS queue using the JMS channel adapter. I have this scenario set up using two channels, and endpoint, and a jms-target in my configuration. Everything is working fine, but here is the rub:

    When my message reaches the JMS queue, it is picked up by another system (that I cannot modify) which looks for a JMSReplyTo field in the JMSMessage header to determine which queue receives the transformed reply message.

    I have the following questions:

    1. Is it possible to set the JMSReplyTo field on my SI StringMessage object using an SI MessageHeader with fooHeader.setAttribute("JMSReplyTo", replyToDestination)?

    2. If that approach is possible, what is the best way to set a MessageHeader ? I see that the GenericMessage.setHeader() method has protected access. Must I subclass GenericMessage or StringMessage to be able to set a header?

    Thanks in advance for any advice on this matter!



  • #2

    Currently, the easiest way to add the JMSReplyTo property would be to set a MessageConverter on the JmsTemplate. For example:
    <si:jms-target jms-template="jmsTemplate" channel="outChannel"/>
    <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
       <property name="connectionFactory" ref="connectionFactory"/>
       <property name="defaultDestinationName" value="queue.out"/>
       <property name="messageConverter">
          <bean class="example.CustomConverter">
              <property name="replyTo" ref="replyDestination"/>
    Then CustomConverter can extend Spring's SimpleMessageConverter, and do something like the following:
    public void setReplyTo(Destination replyTo) {
       this.replyTo = replyTo;
    public Message toMessage(Object o, Session s) {
       Message message = super.toMessage(o, s);
       return message;
    Moving forward, the Spring Integration JmsTargetAdapter should probably be able to recognize these common JMS headers. The keys can be provided as static fields in the adapter itself (e.g. JmsTargetAdapter.JMS_REPLY_TO). Then, what you are trying to do would be much easier. I will add this right now as an M2 issue in Jira.

    To answer your question about the header, you can add attributes like this:
    message.getHeader().setAttribute("key", value);
    Hope that helps,


    • #3
      If you want to check on the progress, here is a link to the Jira issue for this: