Results 1 to 5 of 5

Thread: It seems that the <ws: inbound-gateway> ignores the attribute 'reply-channel'

  1. #1
    Join Date
    May 2011
    Posts
    8

    Default It seems that the <ws: inbound-gateway> ignores the attribute 'reply-channel'

    Guys,

    I trying to intercept the reply of the <ws: inbound-gateway> for logging purpose. But the reply channel never is intercepted.

    Code:
    <int-ws:inbound-gateway id="ws-inbound-gateway"
    		request-channel="wsRequestChannel" 
                    header-mapper="propagateSoapHeaderMapper"
    		reply-channel="wsReplyChannel"
     />
    
    <int:channel id="wsReplyChannel">
    	<int:interceptors>
       	    <int:ref bean="channelInterceptor" />
    	</int:interceptors>
    </int:channel>
    The channelInterceptor implements all pre and post methods (send and receive).

    How can I get the response messages from <ws:inbound-gateway> and log it ?

    Thanks

  2. #2
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,021

    Default

    You need to explicitly send the downstream reply to that channel if you want to intercept it. If you have no output-channel on your final handler, the reply gets sent directly to the reply channel in the replyChannel header and not to the declared channel.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  3. #3
    Join Date
    May 2011
    Posts
    8

    Default

    Gary, works great.

    Summarizing

    The difference between output-channel and reply-channel is a follow:
    a) The output-channel specifies where the outbound-gateway (the last handler message) should put the response
    b) The reply-channel specifies where the inbound-gateway (the first handler message) should get the response that is sent back to the caller;

    Therefore, each reply-channel should be associated with an output-channel, right ?

    If there is a reply-channel, but there is no an output-channel, then the reply-channel will simply be ignored, ok?


    Thanks in advance

  4. #4
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,021

    Default

    That is correct; in general, it is not necessary to specify a reply channel on an inbound gateway; the last reply-producing endpoint (outbound gateway, or transformer, or service-activator, or ...) does not need to specify an output channel.

    The only time this is not the case is when you want do something with the reply channel (such as intercept it, make it publish-subscribe, etc, etc).

    As you say, if there is no final output channel, any reply-channel on the inbound gateway is ignored.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  5. #5
    Join Date
    Jan 2009
    Location
    Ukraine, Kharkov
    Posts
    637

    Default

    Hello

    if there is no final output channel, any reply-channel on the inbound gateway is ignored
    Let me explain why:
    If your last message handler (outbound gateway, or transformer, or service-activator, or ...) does not specify an output-channel it tries to get it from MessageHeaders at REPLY_CHANNEL header.
    Any gateway component implements request/reply pattern. So, it sends message to the request-channel with REPLY_CHANNEL header as some TemporaryReplyChannel instance.
    If you declare reply-channel attribute on your gateway the last one creates on the background some ReplyMessageCorrelator as instance of BridgeHandler before putting message to the request-channel, which just shifts message from reply-channel to the TemporaryReplyChannel from MessageHeaders.REPLY_CHANNEL(it is always here as a gateway puts it to REPLY_CHANNEL before message sending), since this BridgeHandler instance doesn't have any output-channel declaration.
    That's why your message-flow works OK without any last output-channel: it sends message to the TemporaryReplyChannel ignoring the reply-channel.
    So, be careful to change REPLY_CHANNEL header inside your gateway message-flow.
    Also one more caution: since TemporaryReplyChannel isn't Serializable be careful to use some persistance queue inside your gateway's message-flow with default Serializing Strategy(e.g. JdbcMessageStore & DefaultSerializer). In this case REPLY_CHANNEL header will be removed before storing message.

    I hope I didn't miss anything...
    Artem Bilan

Tags for this Thread

Posting Permissions

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