Announcement Announcement Module
Collapse
No announcement yet.
Routing with request-reply Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Routing with request-reply

    I want to create a request-reply transaction where the generic request channel can route the request to other request channel, so the specific handler can handle these requests and response back to the reply channel. I am having some trouble doing that.

    My reply message never get send back to the reply channel. The message was sent back to the same request channel that the handler received the message from.

    1) Message sent from handler
    2) Request Channel received message
    3) Router route message to different channel
    4) Auth Request Channel received message
    5) Handler poll request message and reply
    6) Auth Request channel received message again

    In the message header, the internal.header.returnAddress is the reply channel which I specific in the handler output. However, internal.header.nextTarget was set to the same request channel.

    Is this a limitation in request-reply that does not allow router?

    Thanks,

    Michael

  • #2
    Is this the same problem?

    http://jira.springframework.org/browse/INT-358

    Comment


    • #3
      I think the below covers what you want to do. In this case TestRouter always routes to channelOne as a simplification.

      Code:
      public class TestRouter {
      	
      	@Router
      	public String routeMessage(Message<?> message){
      		return "channelOne";
      	}
      }
      Code:
      <si:channel id="requests"/>
      
      <si:channel id="channelOne">
      	<si:queue capacity="10"/>
      </si:channel>
      
      <si:channel id="replies">
      	<si:queue capacity="10"/>
      </si:channel>
      
      <si:router ref="router" input-channel="requests" />
      <bean id="router" class="TestRouter"/>
      
      <si:service-activator ref="consumerOne" input-channel="channelOne" />
      <bean id="consumerOne" class="TestConsumer"/>
      The message is routed to the TestConsumer which has no output-channel therefore the header that has been set is used to respond back to the replies channel.

      Code:
      MessageBuilder<String> requestBuilder = MessageBuilder.withPayload("test");
      requestBuilder.setReplyChannelName("replies");
      requestChannel.send(requestBuilder.build());
      Message reply = replyChanmel.receive(5000);

      Comment


      • #4
        For some reason, i can't post link in the forum. I think this problem has to do with a bug in spring integration.

        INT-358 - MessageBuilder and MessageHeaders.NEXT_TARGET: Endless loop when using a Router

        Comment


        • #5
          Yes, I believe it is the same issue. You can grab the nightly from the day that issue was resolved. It was almost immediately after the M6 release, so it will be practically identical to M6. Also, RC1 will be released within just a few days.

          Comment

          Working...
          X