Search code examples
muleresponse

When will Mule response phase get ignored?


I am reading Mule in Action book to understand the response phase. In that the author says:

Finally, the last thing to consider is that the outcome of the response phase is ignored if the flow response is returned via reply-to routing.

I do not understand it well. Can any one make me to understand it? Thanks in advance.


Solution

  • Here is an example. Here the request-reply router will add a replyTo header so the result of flow 'replyto' is sent back to the 'replytoout' queue. It will hit the end of the request phase and then return the result without invoking the response phase.

    If you run this you should see the following logged:

    Final value::: B

    Rather than 'C', becuase the response phase is ignored

    <flow name="replytotest">
            <poll frequency="60000">
                <logger level="INFO" message="Starting" />
            </poll>
    
            <set-payload value="A" />
    
            <request-reply>
                <vm:outbound-endpoint address="vm://replytoin" />
                <vm:inbound-endpoint address="vm://replytoout" />
            </request-reply>
    
            <logger level="INFO" message="Final value::: #[payload] " />
        </flow>
    
        <flow name="replyto">
            <vm:inbound-endpoint address="vm://replytoin" />
    
            <set-payload value="B" />
    
            <response>
                <set-payload value="C" />
            </response>
        </flow>