Results 1 to 5 of 5

Thread: Routing with request-reply

  1. #1
    Join Date
    Jul 2008
    Location
    San Jose
    Posts
    22

    Default 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. #2
    Join Date
    Jul 2008
    Location
    San Jose
    Posts
    22

  3. #3
    Join Date
    Oct 2007
    Location
    London, England
    Posts
    108

    Default

    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);
    Jonas Partner
    OpenCredo

  4. #4
    Join Date
    Jul 2008
    Location
    San Jose
    Posts
    22

    Default

    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

  5. #5
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,854

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •