Request-response scope with respect to the request-response exchange pattern

I am trying to understand the use case for a request-response scope if this would be preferable to a request-response response pattern ? Especially if the underlying transport is JMS, I assume using an exchange pattern or scope would do the same internally and functionally from the perspective thread.

There are a couple of issues around using the request-response scope around the correlation id and property response support here and here , would the same issues occur if you use the request-response exchange pattern? (I think yes, can someone please confirm)

Basically when to use request-request over request-response exchange pattern

Update my question to further explore the behavior of the request-response scope.

Experiment with the use of the request-response scope in the first use case mentioned in the accepted answer.

Use case 1

The endpoint itself does not support request-response, and yet you want to simulate synchronicity

I created a thread as below, I tested this without the post properties transformer (same behavior)

Request-reply use case

The actual behavior is that the request is always awaiting, even after the file has been successfully written, the response never arrives at the outbound VM

My flow code is below

<flow name="request-replyflowtest">
        <http:listener config-ref="Orders_HTTP_Listener_Configuration" path="/rr" doc:name="request-reply-test"/>
        <set-payload value="Hello world" doc:name="Set Payload"/>
        <message-properties-transformer overwrite="true" doc:name="Message Properties" >
            <add-message-property key="MULE_REPLYTO" value="vm://back"/>
             <add-message-property key="MULE_CORRELATION_ID" value="#[java.util.UUID.randomUUID().toString()]"/>
        </message-properties-transformer>
        <request-reply doc:name="Request-Reply">
            <file:outbound-endpoint path="C:\Users\sudarshan.sreenivasan\Desktop" outputPattern="hello.txt" responseTimeout="10000" doc:name="File"/>
            <vm:inbound-endpoint exchange-pattern="one-way" path="back" doc:name="VM"/>
        </request-reply>
         <logger message="response not written out" level="INFO" doc:name="Logger"/>
        <set-payload value="This is from a different flow" doc:name="Set Payload"/>
    </flow>

      

+3


source to share


1 answer


As such, you should ask for a request-response in most cases, unless:



  • The endpoint itself does not support request-response, and yet you want to simulate synchronicity.
  • You want to send a request for one mode of transport and wait for a response on another, i.e. send to jms await response in amqp
  • You want to send a request to one socket and wait for a response on the other, i.e. send to jms-connector, wait for response jms-connector b
+4


source







All Articles