Announcement Announcement Module
No announcement yet.
Setting destination queue dynamically Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Setting destination queue dynamically


    My application receives a JMS message which would contain the name of the queue to which it should reply. The application receives the message, does some processing and replies on the 'reply queue' in the message received

    I know how to configure the Queue but, is there any way to do this dynamically in Spring Integration?

  • #2
    If you just need dynamically reply set REPLY_CHANNEL message header and the service activator sends message to the right queue. It's default behaviour.


    • #3
      I am kind of new to this,

      can you please send me a code snippet?


      • #4
        I would have the queue name to which I need to reply, I want this to be dynamic and dont want to configure a channel for a queue.


        • #5

          If you are using an "inbound-gateway" element within the JMS namespace, it will automatically use the JMSReplyTo property on any incoming JMS Message when it sends a reply Message.


          • #6
            Ok here is what my program needs to do ---

            1. Receive a jms process
            2. convert the message to a java object(xml beans)
            3. serialize the file to a location A

            I have another file poller component which needs to do the following

            1. Keep polling location A for any new files
            2. Deserialize the file to a java object
            3. Do some processing
            4. Send a reply message to a queue(the name of the queue is in the above deserialized object)

            I am able to do everthing except the # 4 in the second component. Can you help me do this?

            Thanks in advance


            • #7
              Can you provide some excerpts from your configuration? It would be helpful to see the endpoints and settings that you are currently using for these steps in order to make recommendations for changes and/or additions.



              • #8
                I have attached my configuration file, I need to send the reply message through the 'stampReplyPublisher' bean.

                Let me know if you need anything else.


                • #9
                  I don't see any File polling. Are you planning to add that later?

                  The main thing I was wondering about is how you are serializing/deserializing. You are somehow going to need to preserve the JMS reply-to header. It is available on the original Message sent to your "transformChannelInput" channel.

                  By the way, here is a nice trick for viewing the Message as well as its headers at any point within the message flow:
                  <channel id="in">
                          <wire-tap channel="logger"/>
                  <logging-channel-adapter id="logger" level="DEBUG"/>


                  • #10
                    The serialization and deserialization happens in the service activator 'stampRequestReceiver'. The service activator serializes to a pre-configured folder, the file poller would pick up the files from this folder and some processsing is done. I need to send the message at this point.

                    Note: currently I have a work around - I inject the jmstemplate into 'smallAttachmentProcessor' message end point and use it to send reply messages, but I would like to know if there is any other better way.

                    Attaching the remaining files...


                    • #11
                      The JMS inbound-gateway handles a reply-to header for sending replies based on the original request message. However, it sounds like in your case there is a potential for long delays between the original JMS message being received and the reply being sent since you have a file poller in the middle of the process.