title: How Return Payload to Caller Flow With ActiveMQ in Mule?
body: <pre><code>&lt;jms:activemq-connector name="jms-connector"  brokerURL="${BrokerURL}" disableTemporaryReplyToDestinations="true"  maxRedelivery="10" durable="true" specification="1.1"/&gt;
  &lt;jms:endpoint connector-ref="jms-connector"  name="SyncRequestsQueue" queue="SyncRequestsQueue"&gt;
      &lt;jms:transaction action="ALWAYS_BEGIN"/&gt;
  &lt;/jms:endpoint&gt;
  
  &lt;flow name = "RequestsEntryFlow" &gt;
      &lt;http:listener allowedMethods="POST"  parseRequest="false"  config-ref="HTTP_Request_Listener" path="/{name}" doc:name="HTTP Entry Flow" /&gt;
      &lt;flow-ref name="requestBeanCreate" /&gt;
      &lt;jms:outbound-endpoint connector-ref="jms-connector" exchange-pattern="request-response" ref="SyncRequestsQueue" /&gt; 
  &lt;/flow&gt;
  
  &lt;flow name = "SyncRequestsQueueConsumer"&gt;
      &lt;jms:inbound-endpoint  connector-ref="jms-connector" exchange-pattern="request-response" ref="SyncRequestsQueue" /&gt;
      &lt;set-variable variableName="id" value="#[payload]" doc:name="Variable" /&gt;
      &lt;set-variable variableName="destination" value="#[app.registry.routerBean.getDestination(app.registry.messageBean.getReceiverID(payload))]"  doc:name="Variable" /&gt;
      &lt;set-payload value="#[app.registry.messageBean.sendRequestToDestination(payload)]" /&gt;
      &lt;processor-chain&gt;
          &lt;http:outbound-endpoint address="http://#[flowVars.destination]" exchange-pattern="request-response"&gt;
               &lt;transformer ref="contentTypeTextXML"/&gt;
          &lt;/http:outbound-endpoint&gt;                     
          &lt;expression-component&gt;
              app.registry.messageBean.sendResponseToSender(flowVars.id);
              app.registry.messageBean.messageProcessedSuccessfully(flowVars.id);
          &lt;/expression-component&gt;
      &lt;/processor-chain&gt;
  &lt;/flow&gt;
  </code></pre>
  
  <p>This is the scenario:</p>
  
  <p>A requests to a remote service comes in to RequestsEntryFlow. 
  I do some logging stuff with it and send it to SyncRequestsQueue. 
  The SyncRequestsQueueConsumer consumes the queue and sends the content to a remote server.
  Now i want to return the response of remote server back to RequestsEntryFlow and from there back to the service Caller.
  but the response is not getting back to service caller.</p>
  
  <p>note: when i eliminate JMS and Activemq from the code and use SyncRequestsQueueConsumer as a sub-flow everything works fine. so i guess JMS connectors are not working the way i need them.</p>
  
  <p>What is wrong with the code and how can i solve it? thank you </p>
  
  <p><strong>--EDIT--</strong></p>
  
  <p>I have changed my code to adopt  scope and now it looks like this :</p>
  
  <pre><code>&lt;flow name = "RequestsEntryFlow" &gt;
      &lt;http:listener allowedMethods="POST"  parseRequest="false"  config-ref="HTTP_Request_Listener" path="/{name}" doc:name="HTTP Entry Flow" /&gt;
      &lt;flow-ref name="requestBeanCreate" /&gt;                          
  
      &lt;choice doc:name="Choice"&gt;
          &lt;when expression="#[app.registry.messageBean.isEMCRequired(payload)]"&gt;
              &lt;jms:outbound-endpoint connector-ref="jms-connector"  ref="EMCRequiredRequestsQueue" /&gt;
          &lt;/when&gt;
          &lt;otherwise&gt;                         
           &lt;request-reply&gt;
                  &lt;jms:outbound-endpoint connector-ref="jms-connector" exchange-pattern="one-way" ref="SyncRequestsQueue" /&gt;
                  &lt;jms:inbound-endpoint connector-ref="jms-connector" exchange-pattern="one-way"  queue="ResponseTempQueue" &gt;
                      &lt;set-payload value="#[payload.get(0)]"/&gt;
                      &lt;remove-property propertyName="Content_Type"/&gt;
                      &lt;transformer ref="contentTypeTextXML"/&gt;
                  &lt;/jms:inbound-endpoint&gt;
               &lt;/request-reply&gt;
          &lt;/otherwise&gt;
      &lt;/choice&gt;        
  &lt;/flow&gt;
  
  &lt;flow name = "SyncRequestsQueueConsumer"&gt;
      &lt;jms:inbound-endpoint connector-ref="jms-connector" exchange-pattern="request-response" ref="SyncRequestsQueue" /&gt;
      &lt;set-variable variableName="id" value="#[payload]" doc:name="Variable" /&gt;
      &lt;set-variable variableName="destination" value="#[app.registry.routerBean.getDestination(app.registry.messageBean.getReceiverID(payload))]"  doc:name="Variable" /&gt;
      &lt;set-payload value="#[app.registry.messageBean.sendRequestToDestination(payload)]" /&gt;
  
      &lt;http:outbound-endpoint address="http://#[flowVars.destination]" exchange-pattern="request-response"&gt;
      &lt;transformer ref="contentTypeTextXML"/&gt;
      &lt;/http:outbound-endpoint&gt;                          
      &lt;expression-component&gt;
          app.registry.messageBean.sendResponseToSender(flowVars.id);
          app.registry.messageBean.messageProcessedSuccessfully(flowVars.id);
      &lt;/expression-component&gt;
  
  &lt;/flow&gt;
  </code></pre>
  
  <p>If i add e logger to my code it will print the proper payload (the response from server) </p>
  
  <pre><code>                &lt;jms:inbound-endpoint connector-ref="jms-connector" exchange-pattern="one-way"  queue="ResponseTempQueue" &gt;
                      &lt;set-payload value="#[payload.get(0)]"/&gt;
                      &lt;remove-property propertyName="Content_Type"/&gt;
                      &lt;transformer ref="contentTypeTextXML"/&gt;
                      &lt;logger level="INFO" message="#[payload]" /&gt;
                  &lt;/jms:inbound-endpoint&gt;
  </code></pre>
  
  <p>but the response is not routing back to sender through HTTP </p>