Mule - Message Splitter and Response Aggregation for a synchronous flow - mule

I am facing issues while trying the following scenario in mule esb:
Main Flow
1) Makes a http request to get a payload say in the following format:
<result><row><event_key>4457573</event_key><show_title>The Book of Mormon Houston</show_title><venue_name>Sarofim Hall at The Hobby Center in Houston, US</venue_name><perf_date>01/28/2015 12:00:00 AM</perf_date><area>CENTER ORCHESTRA</area><row_desc>XN</row_desc><seat_num>20</seat_num><seat_increment>1</seat_increment><Cost>903</Cost></row><row><event_key>4457573</event_key><show_title>The Book of Mormon Houston</show_title><venue_name>Sarofim Hall at The Hobby Center in Houston, US</venue_name><perf_date>01/28/2015 12:00:00 AM</perf_date><area>CENTER ORCHESTRA</area><row_desc>XN</row_desc><seat_num>21</seat_num><seat_increment>1</seat_increment><Cost>904</Cost></row><row><event_key>4457573</event_key><show_title>The Book of Mormon Houston</show_title><venue_name>Sarofim Hall at The Hobby Center in Houston, US</venue_name><perf_date>01/28/2015 12:00:00 AM</perf_date><area>CENTER ORCHESTRA</area><row_desc>XN</row_desc><seat_num>22</seat_num><seat_increment>1</seat_increment><Cost>905</Cost></row><row><event_key>4457573</event_key><show_title>The Book of Mormon Houston</show_title><venue_name>Sarofim Hall at The Hobby Center in Houston, US</venue_name><perf_date>01/28/2015 12:00:00 AM</perf_date><area>CENTER ORCHESTRA</area><row_desc>XN</row_desc><seat_num>23</seat_num><seat_increment>1</seat_increment><Cost>905</Cost></row></result>
2) Transforms that payload by applying some logic to an xml of this format.
<listings>
<listing>
<eventId>4457573</eventId>
<eventDescription>The Book of Mormon Houston</eventDescription>
<pricePerTicket>
<amount>903</amount>
<currency>USD</currency>
</pricePerTicket>
<quantity>1</quantity>
<section>CENTER ORCHESTRA</section>
<rows>XN</rows>
<seats>20</seats>
<splitOption>NONE</splitOption>
</listing>
<listing>
<eventId>4457573</eventId>
<eventDescription>The Book of Mormon Houston</eventDescription>
<pricePerTicket>
<amount>904</amount>
<currency>USD</currency>
</pricePerTicket>
<quantity>1</quantity>
<section>CENTER ORCHESTRA</section>
<rows>XN</rows>
<seats>21</seats>
<splitOption>NONE</splitOption>
</listing>
<listing>
<eventId>4457573</eventId>
<eventDescription>The Book of Mormon Houston</eventDescription>
<pricePerTicket>
<amount>905</amount>
<currency>USD</currency>
</pricePerTicket>
<quantity>2</quantity>
<section>CENTER ORCHESTRA</section>
<rows>XN</rows>
<seats>22,23</seats>
<splitOption>NONE</splitOption>
</listing>
</listings>
3) Splits the messages using splitter
<splitter enableCorrelation="ALWAYS" expression="#[xpath('//listings/listing')]" doc:name="ListingRequestSplitter"/>
4) Uses request-reply router to route those messages to dispatchIn VM queue
<request-reply storePrefix="listmsg" doc:name="Put message for processing">
<vm:outbound-endpoint path="dispatchIn">
<message-properties-transformer scope="outbound">
<delete-message-property key="MULE_REPLYTO" />
</message-properties-transformer>
</vm:outbound-endpoint>
<vm:inbound-endpoint path="dispatchOut" />
</request-reply>
5) Second flow which is processing listening to dispatchIn queue
<flow name="ListingMessageProcessorFlow" doc:name="ListingMessageProcessorFlow">
<vm:inbound-endpoint path="dispatchIn"/>
<message-properties-transformer scope="invocation" doc:name="Remember correlation">
<add-message-property value="#[header:OUTBOUND:MULE_CORRELATION_ID]" key="cid" />
<add-message-property value="#[header:OUTBOUND:MULE_CORRELATION_GROUP_SIZE]" key="cgs" />
</message-properties-transformer>
<logger message="ListingMessageProcessorFlow - Splitted Message : #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
<https:outbound-endpoint exchange-pattern="request-response" host="api-dev.srwd10.com" port="443" path="inventory/listings/v1/" method="POST" doc:name="HTTP" connector-ref="HTTP_HTTPS" transformer-refs="DOM_to_XML" contentType="application/xml" mimeType="application/xml">
<message-properties-transformer scope="outbound">
<add-message-property key="Authorization" value="Bearer 8da2ba50b471958168dfe0d4efd0f428" />
<add-message-property key="TARGET_HOST" value="srwq12" />
<add-message-property key="Acccept" value="application/xml" />
</message-properties-transformer>
</https:outbound-endpoint>
<message-properties-transformer scope="outbound">
<add-message-property value="#[header:INVOCATION:cid]" key="MULE_CORRELATION_ID" />
<add-message-property value="#[header:INVOCATION:cgs]" key="MULE_CORRELATION_GROUP_SIZE" />
</message-properties-transformer>
<vm:outbound-endpoint path="vm.aggregate" />
</flow>
<flow name="ListingMessageResponseAggregator">
<vm:inbound-endpoint path="vm.aggregate" />
<logger message="ListingMessageResponseAggregator - CorelationID : #[header:MULE_CORRELATION_ID], CorelationGroupSize : #[header:MULE_CORRELATION_GROUP_SIZE], Payload : #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
<collection-aggregator doc:name="Collection Aggregator" />
<vm:outbound-endpoint path="dispatchOut" />
</flow>
6) request-reply outbound configuration pushing the messages to a dispatchOut queue.
I am seeing that only first message gets processed and rest all messages just get into timeout state. Can someone help if I am doing something wrong here. Here is the complete configuration:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:https="http://www.mulesoft.org/schema/mule/https" xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.5.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd
http://www.mulesoft.org/schema/mule/https http://www.mulesoft.org/schema/mule/https/current/mule-https.xsd">
<!-- HTTPS Connection Configuration With CERTS -->
<https:connector name="HTTP_HTTPS" cookieSpec="netscape" validateConnections="true" sendBufferSize="0" receiveBufferSize="0" receiveBacklog="0" clientSoTimeout="10000" serverSoTimeout="10000" socketSoLinger="0" doc:name="HTTP-HTTPS">
<https:tls-server path="/Users/rkesara/opt/MULE/truststore/cacerts" storePassword="changeit" />
</https:connector>
<!-- List of transformers that might be useful for this flow -->
<mulexml:dom-to-xml-transformer outputEncoding="UTF-8" name="DOM_to_XML" doc:name="DOM to XML"/>
<!-- Root flow that can trigger pull and push functionality -->
<flow name="PullAndPushInventoryFlow" doc:name="PullAndPushInventoryFlow">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
<logger message="Inside PullAndPushInventoryFlow - QueryParams : #[message.inboundProperties.'http.query.params']" level="INFO" doc:name="Logger"/>
<logger message="PullAndPushInventoryFlow - Invoking GetLocationList API" level="INFO" doc:name="Logger"/>
<http:outbound-endpoint exchange-pattern="request-response" host="srwq12csb001.srwq12.com" port="8280" path="services/t/telecharge.com/GetLocationList/?eventId=4457573&rows=XN&seatFrom=20&seatTo=40&costMin=900&costMax=910" method="GET" doc:name="HTTP"/>
<logger message="PullAndPushInventoryFlow - Applying bundling logic to create SH listing requests on telecharge payload : #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
<mulexml:xslt-transformer maxIdleTransformers="2" maxActiveTransformers="5" doc:name="XSLT" xsl-file="src/main/resources/xslt/listingrequest.xsl" />
<logger message="PullAndPushInventoryFlow - Listing requests payload after bunlding : #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
<logger message="PullAndPushInventoryFlow - Splitting listing requests..." level="INFO" doc:name="Logger"/>
<splitter enableCorrelation="ALWAYS" expression="#[xpath('//listings/listing')]" doc:name="ListingRequestSplitter"/>
<logger message="PullAndPushInventoryFlow - Number of listing requests found after bunlding : #[header:MULE_CORRELATION_GROUP_SIZE]" level="INFO" doc:name="Logger"/>
<request-reply storePrefix="listmsg" doc:name="Put message for processing">
<vm:outbound-endpoint path="dispatchIn">
<message-properties-transformer scope="outbound">
<delete-message-property key="MULE_REPLYTO" />
</message-properties-transformer>
</vm:outbound-endpoint>
<vm:inbound-endpoint path="dispatchOut" />
</request-reply>
<logger message="Aggregated Payload-> #[payload]" level="INFO" doc:name="Logger"/>
</flow>
<flow name="ListingMessageProcessorFlow" doc:name="ListingMessageProcessorFlow">
<vm:inbound-endpoint path="dispatchIn"/>
<message-properties-transformer scope="invocation" doc:name="Remember correlation">
<add-message-property value="#[header:OUTBOUND:MULE_CORRELATION_ID]" key="cid" />
<add-message-property value="#[header:OUTBOUND:MULE_CORRELATION_GROUP_SIZE]" key="cgs" />
</message-properties-transformer>
<logger message="ListingMessageProcessorFlow - Splitted Message : #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
<https:outbound-endpoint exchange-pattern="request-response" host="api-dev.srwd10.com" port="443" path="inventory/listings/v1/" method="POST" doc:name="HTTP" connector-ref="HTTP_HTTPS" transformer-refs="DOM_to_XML" contentType="application/xml" mimeType="application/xml">
<message-properties-transformer scope="outbound">
<add-message-property key="Authorization" value="Bearer 8da2ba50b471958168dfe0d4efd0f428" />
<add-message-property key="TARGET_HOST" value="srwq12" />
<add-message-property key="Acccept" value="application/xml" />
</message-properties-transformer>
</https:outbound-endpoint>
<message-properties-transformer scope="outbound">
<add-message-property value="#[header:INVOCATION:cid]" key="MULE_CORRELATION_ID" />
<add-message-property value="#[header:INVOCATION:cgs]" key="MULE_CORRELATION_GROUP_SIZE" />
</message-properties-transformer>
<vm:outbound-endpoint path="vm.aggregate" />
</flow>
<flow name="ListingMessageResponseAggregator">
<vm:inbound-endpoint path="vm.aggregate" />
<logger message="ListingMessageResponseAggregator - CorelationID : #[header:MULE_CORRELATION_ID], CorelationGroupSize : #[header:MULE_CORRELATION_GROUP_SIZE], Payload : #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
<collection-aggregator doc:name="Collection Aggregator" failOnTimeout="false"/>
<vm:outbound-endpoint path="dispatchOut" />
</flow>
</mule>
Just to add detailed logs of what is happening:
INFO 2014-06-12 16:00:15,617 [[telecharge].connector.http.mule.default.receiver.04] org.mule.api.processor.LoggerMessageProcessor: Inside PullAndPushInventoryFlow - QueryParams : {}
INFO 2014-06-12 16:00:15,617 [[telecharge].connector.http.mule.default.receiver.04] org.mule.api.processor.LoggerMessageProcessor: PullAndPushInventoryFlow - Invoking GetLocationList API on telecharge
INFO 2014-06-12 16:00:16,213 [[telecharge].connector.http.mule.default.receiver.04] org.mule.api.processor.LoggerMessageProcessor: PullAndPushInventoryFlow - Applying bundling logic to create SH listing requests on telecharge payload : <result><row><event_key>4457573</event_key><show_title>The Book of Mormon Houston</show_title><venue_name>Sarofim Hall at The Hobby Center in Houston, US</venue_name><perf_date>01/28/2015 12:00:00 AM</perf_date><area>CENTER ORCHESTRA</area><row_desc>XN</row_desc><seat_num>20</seat_num><seat_increment>1</seat_increment><Cost>903</Cost></row><row><event_key>4457573</event_key><show_title>The Book of Mormon Houston</show_title><venue_name>Sarofim Hall at The Hobby Center in Houston, US</venue_name><perf_date>01/28/2015 12:00:00 AM</perf_date><area>CENTER ORCHESTRA</area><row_desc>XN</row_desc><seat_num>21</seat_num><seat_increment>1</seat_increment><Cost>904</Cost></row><row><event_key>4457573</event_key><show_title>The Book of Mormon Houston</show_title><venue_name>Sarofim Hall at The Hobby Center in Houston, US</venue_name><perf_date>01/28/2015 12:00:00 AM</perf_date><area>CENTER ORCHESTRA</area><row_desc>XN</row_desc><seat_num>22</seat_num><seat_increment>1</seat_increment><Cost>905</Cost></row><row><event_key>4457573</event_key><show_title>The Book of Mormon Houston</show_title><venue_name>Sarofim Hall at The Hobby Center in Houston, US</venue_name><perf_date>01/28/2015 12:00:00 AM</perf_date><area>CENTER ORCHESTRA</area><row_desc>XN</row_desc><seat_num>23</seat_num><seat_increment>1</seat_increment><Cost>905</Cost></row></result>
INFO 2014-06-12 16:00:16,221 [[telecharge].connector.http.mule.default.receiver.04] org.mule.api.processor.LoggerMessageProcessor: PullAndPushInventoryFlow - Listing requests payload after bunlding : <?xml version="1.0" encoding="UTF-8"?>
<listings>
<listing>
<eventId>4457573</eventId>
<eventDescription>The Book of Mormon Houston</eventDescription>
<pricePerTicket>
<amount>903</amount>
<currency>USD</currency>
</pricePerTicket>
<quantity>1</quantity>
<section>CENTER ORCHESTRA</section>
<rows>XN</rows>
<seats>20</seats>
<splitOption>NONE</splitOption>
</listing>
<listing>
<eventId>4457573</eventId>
<eventDescription>The Book of Mormon Houston</eventDescription>
<pricePerTicket>
<amount>904</amount>
<currency>USD</currency>
</pricePerTicket>
<quantity>1</quantity>
<section>CENTER ORCHESTRA</section>
<rows>XN</rows>
<seats>21</seats>
<splitOption>NONE</splitOption>
</listing>
<listing>
<eventId>4457573</eventId>
<eventDescription>The Book of Mormon Houston</eventDescription>
<pricePerTicket>
<amount>905</amount>
<currency>USD</currency>
</pricePerTicket>
<quantity>2</quantity>
<section>CENTER ORCHESTRA</section>
<rows>XN</rows>
<seats>22,23</seats>
<splitOption>NONE</splitOption>
</listing>
</listings>
INFO 2014-06-12 16:00:16,221 [[telecharge].connector.http.mule.default.receiver.04] org.mule.api.processor.LoggerMessageProcessor: PullAndPushInventoryFlow - Splitting listing requests...
INFO 2014-06-12 16:00:16,231 [[telecharge].connector.http.mule.default.receiver.04] org.mule.api.processor.LoggerMessageProcessor: PullAndPushInventoryFlow - Number of listing requests found after bunlding : 9
INFO 2014-06-12 16:00:16,232 [[telecharge].connector.http.mule.default.receiver.04] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'connector.VM.mule.default.dispatcher.521391459'. Object is: VMMessageDispatcher
INFO 2014-06-12 16:00:16,232 [[telecharge].connector.http.mule.default.receiver.04] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'connector.VM.mule.default.dispatcher.521391459'. Object is: VMMessageDispatcher
INFO 2014-06-12 16:00:16,236 [[telecharge].ListingMessageProcessorFlow.stage1.02] org.mule.api.processor.LoggerMessageProcessor: ListingMessageProcessorFlow - Splitted Message : <listing>
<eventId>4457573</eventId>
<eventDescription>The Book of Mormon Houston</eventDescription>
<pricePerTicket>
<amount>903</amount>
<currency>USD</currency>
</pricePerTicket>
<quantity>1</quantity>
<section>CENTER ORCHESTRA</section>
<rows>XN</rows>
<seats>20</seats>
<splitOption>NONE</splitOption>
</listing>
INFO 2014-06-12 16:00:16,238 [[telecharge].ListingMessageProcessorFlow.stage1.02] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default outbound transformer: org.mule.transport.http.transformers.ObjectToHttpClientMethodRequest
INFO 2014-06-12 16:00:16,238 [[telecharge].ListingMessageProcessorFlow.stage1.02] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default response transformer: org.mule.transport.http.transformers.MuleMessageToHttpResponse
INFO 2014-06-12 16:00:16,238 [[telecharge].ListingMessageProcessorFlow.stage1.02] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default outbound transformer: org.mule.transport.http.transformers.ObjectToHttpClientMethodRequest
INFO 2014-06-12 16:00:16,238 [[telecharge].ListingMessageProcessorFlow.stage1.02] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'HTTP_HTTPS.dispatcher.1221616365'. Object is: HttpsClientMessageDispatcher
INFO 2014-06-12 16:00:16,238 [[telecharge].ListingMessageProcessorFlow.stage1.02] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'HTTP_HTTPS.dispatcher.1221616365'. Object is: HttpsClientMessageDispatcher
WARN 2014-06-12 16:00:17,658 [[telecharge].ListingMessageProcessorFlow.stage1.02] org.apache.commons.httpclient.HttpMethodBase: Cookie rejected: "$Version=0; TLTSID=4FE5E730F28510F29E93A683F88FB10C; $Path=/; $Domain=.srwq12.com". Illegal domain attribute ".srwq12.com". Domain of origin: "api-dev.srwd10.com"
INFO 2014-06-12 16:00:17,660 [[telecharge].connector.VM.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'connector.VM.mule.default.dispatcher.222031696'. Object is: VMMessageDispatcher
INFO 2014-06-12 16:00:17,660 [[telecharge].connector.VM.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'connector.VM.mule.default.dispatcher.222031696'. Object is: VMMessageDispatcher
INFO 2014-06-12 16:00:17,664 [[telecharge].ListingMessageResponseAggregator.stage1.02] org.mule.api.processor.LoggerMessageProcessor: ListingMessageResponseAggregator - CorelationID : 5168ed50-f285-11e3-b82a-28cfe91ad417, CorelationGroupSize : 9, Payload : {"listing":{"id":"1082795830","status":"ACTIVE"}}

Might not be a correct solution for my initial question to deal with large number of elements in payload but i found a synchronous way to deal with list of requests. I still have to transform the response at the end but atleast the aggregated payload is coming up fine:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:https="http://www.mulesoft.org/schema/mule/https" xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.5.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd
http://www.mulesoft.org/schema/mule/https http://www.mulesoft.org/schema/mule/https/current/mule-https.xsd">
<!-- HTTPS Connection Configuration With CERTS -->
<https:connector name="HTTP_HTTPS" cookieSpec="netscape" validateConnections="true" sendBufferSize="0" receiveBufferSize="0" receiveBacklog="0" clientSoTimeout="10000" serverSoTimeout="10000" socketSoLinger="0" doc:name="HTTP-HTTPS">
<https:tls-server path="/Users/rkesara/opt/MULE/truststore/cacerts" storePassword="changeit" />
</https:connector>
<!-- List of transformers that might be useful for this flow -->
<mulexml:dom-to-xml-transformer outputEncoding="UTF-8" name="DOM_to_XML" doc:name="DOM to XML"/>
<!-- Root flow that can trigger pull and push functionality -->
<flow name="PullAndPushInventoryFlow" doc:name="PullAndPushInventoryFlow">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
<logger message="Inside PullAndPushInventoryFlow - QueryParams : #[message.inboundProperties.'http.query.params']" level="INFO" doc:name="Logger"/>
<logger message="PullAndPushInventoryFlow - Invoking GetLocationList API on telecharge" level="INFO" doc:name="Logger"/>
<http:outbound-endpoint exchange-pattern="request-response" host="srwq12csb001.srwq12.com" port="8280" path="services/t/telecharge.com/GetLocationList/?eventId=4457573&rows=XO&seatFrom=1&seatTo=6&costMin=900&costMax=905" method="GET" doc:name="HTTP"/>
<logger message="PullAndPushInventoryFlow - Applying bundling logic to create SH listing requests on telecharge payload : #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
<mulexml:xslt-transformer maxIdleTransformers="2" maxActiveTransformers="5" doc:name="XSLT" xsl-file="src/main/resources/xslt/listingrequest.xsl" />
<logger message="PullAndPushInventoryFlow - Listing requests payload after bunlding : #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
<logger message="PullAndPushInventoryFlow - Splitting listing requests..." level="INFO" doc:name="Logger"/>
<splitter enableCorrelation="ALWAYS" expression="#[xpath('//listings/listing')]" doc:name="ListingRequestSplitter"/>
<logger message="PullAndPushInventoryFlow - Number of listing requests found after bunlding : #[header:MULE_CORRELATION_GROUP_SIZE] - current request number : #[header:MULE_CORRELATION_SEQUENCE]" level="INFO" doc:name="Logger"/>
<flow-ref name="ListingMessageProcessorFlow" />
<collection-aggregator />
<logger message="Aggregated Payload-> #[payload]" level="INFO" doc:name="Logger"/>
</flow>
<flow name="ListingMessageProcessorFlow" doc:name="ListingMessageProcessorFlow">
<message-properties-transformer scope="invocation" doc:name="Remember correlation">
<add-message-property value="#[header:OUTBOUND:MULE_CORRELATION_ID]" key="cid" />
<add-message-property value="#[header:OUTBOUND:MULE_CORRELATION_GROUP_SIZE]" key="cgs" />
</message-properties-transformer>
<logger message="ListingMessageProcessorFlow - Invoking listingAPI with request payload : #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
<https:outbound-endpoint exchange-pattern="request-response" host="api-dev.srwd10.com" port="443" path="inventory/listings/v1/" method="POST" doc:name="HTTP" connector-ref="HTTP_HTTPS" transformer-refs="DOM_to_XML" contentType="application/xml" mimeType="application/xml">
<message-properties-transformer scope="outbound">
<add-message-property key="Authorization" value="Bearer 8da2ba50b471958168dfe0d4efd0f428" />
<add-message-property key="TARGET_HOST" value="srwq12" />
<add-message-property key="Acccept" value="application/xml" />
</message-properties-transformer>
</https:outbound-endpoint>
<logger message="ListingMessageProcessorFlow - Listing API response : #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
<message-properties-transformer scope="outbound">
<add-message-property value="#[header:INVOCATION:cid]" key="MULE_CORRELATION_ID" />
<add-message-property value="#[header:INVOCATION:cgs]" key="MULE_CORRELATION_GROUP_SIZE" />
</message-properties-transformer>
</flow>
</mule>

I found the answer for async way of dealing with the issue too..
Full credit to this blog: (http://geekyprimitives.wordpress.com/2012/08/11/fork-and-join-with-mule-3/)
Here is how the async way will work using a request reply router:
<flow name="SimpleFilePollingFlow" doc:name="Simple File Polling">
<file:inbound-endpoint path="/Users/rkesara/opt/MULE/File" responseTimeout="10000" doc:name="ListingRequestsXmlFile">
<file:filename-wildcard-filter pattern="*.xml"/>
</file:inbound-endpoint>
<logger message="SimpleFilePollingFlow - File read successfully and contents : #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
<mulexml:xslt-transformer maxIdleTransformers="2" maxActiveTransformers="5" xsl-file="xslt/listingrequest.xsl" doc:name="BundleListingsUsingXSLT"/>
<transformer ref="DOM_to_XML" />
<request-reply doc:name="Split and process listing messages asynchronously">
<vm:outbound-endpoint path="listingRequestQueue" doc:name="listingRequestQueue">
<message-properties-transformer scope="outbound">
<delete-message-property key="MULE_REPLYTO" />
</message-properties-transformer>
</vm:outbound-endpoint>
<vm:inbound-endpoint path="listingResponseQueue" doc:name="listingResponseQueue" />
</request-reply>
<json:json-to-object-transformer returnClass="java.util.List" doc:name="JSON Array to List" />
<logger message="SimpleFilePollingFlow -Aggregated JSON-> #[payload]" level="INFO" doc:name="Logger"/>
<set-payload value="{"listings": #[payload]}" doc:name="Set Payload"/>
<logger message="SimpleFilePollingFlow - Aggregated JSON With Root Element -> #[payload]" level="INFO" doc:name="Logger"/>
<response>
<http:response-builder status="200" contentType="application/json" doc:name="HTTP Response Builder"/>
</response>
</flow>
<flow name="ListingRequestQueueFlow" doc:name="Listing Request Queue Processor">
<vm:inbound-endpoint path="listingRequestQueue" doc:name="listingRequestQueue" />
<logger message="Inside ListingRequestQueueFlow - payload : #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
<splitter enableCorrelation="ALWAYS" expression="#[xpath('//listings/listing')]" doc:name="ListingRequestSplitter" />
<logger message="Inside ListingRequestQueueFlow - NumOfListingRequests : #[header:MULE_CORRELATION_GROUP_SIZE]" level="INFO" doc:name="Logger"/>
<flow-ref name="ListingRequestWorkerFlow" doc:name="Invoke Listing Request Worker Flow" />
</flow>
<flow name="ListingRequestWorkerFlow" doc:name="Listing Request Worker Flow" processingStrategy="allow500Threads">
<message-properties-transformer scope="invocation" doc:name="Remember correlation">
<add-message-property value="#[header:OUTBOUND:MULE_CORRELATION_ID]" key="cid" />
<add-message-property value="#[header:OUTBOUND:MULE_CORRELATION_GROUP_SIZE]" key="cgs" />
</message-properties-transformer>
<logger message="ListingRequestWorkerFlow - Invoking listingAPI with request payload : #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
<https:outbound-endpoint exchange-pattern="request-response" host="api-dev.srwd10.com" port="443" path="inventory/listings/v1/" method="POST" doc:name="HTTP" connector-ref="HTTP_HTTPS" transformer-refs="DOM_to_XML" contentType="application/xml" mimeType="application/xml" responseTimeout="180000">
<message-properties-transformer scope="outbound">
<add-message-property key="Acccept" value="application/xml" />
</message-properties-transformer>
</https:outbound-endpoint>
<logger message="ListingRequestWorkerFlow - Listing API response for request number : #[header:MULE_CORRELATION_SEQUENCE], group size : #[header:INVOCATION:cgs], Payload: #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
<message-properties-transformer doc:name="Message Properties">
<add-message-property value="#[header:INVOCATION:cid]" key="MULE_CORRELATION_ID" />
<add-message-property value="#[header:INVOCATION:cgs]" key="MULE_CORRELATION_GROUP_SIZE" />
</message-properties-transformer>
<vm:outbound-endpoint path="listingResponseAggregatorQueue" doc:name="ListingResponseAggregatorQueue" />
</flow>
<flow name="ListingResponseAggregatorFlow" doc:name="Listing Response Aggregator">
<vm:inbound-endpoint path="listingResponseAggregatorQueue" doc:name="Listing Response Aggregator Queue"/>
<logger message="ListingResponseAggregatorFlow - request number : #[header:MULE_CORRELATION_SEQUENCE], group size : #[header:MULE_CORRELATION_GROUP_SIZE] - payload : #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
<collection-aggregator failOnTimeout="false" />
<vm:outbound-endpoint path="listingResponseQueue" doc:name="Listing Response Queue" />
</flow>

Related

Counter not work properly while using collection splitter mule esb

I read data from salesforce and split it using collection splitter. I want to aggregate all data into single list. First I count all records and I set that counter with MULE_CORRELATION_GROUP_SIZE. But my counter gives me wrong count..And my data didn't aggregate..
How can I solve this problem
Is my following flow right?
Following is my code
<flow name="davesalesforceFlow1Tmp" doc:name="davesalesforceFlow1Tmp">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" doc:name="HTTP" path="test" contentType="text/plain" />
<sfdc:query config-ref="salesforce" doc:name="Salesforce" query="My query"/>
<collection-splitter doc:name="Collection Splitter"/>
<set-session-variable variableName="cnt"
value="#[org.mule.util.StringUtils.countMatches(message.payload, '\n') + org.mule.util.StringUtils.countMatches(message.payload, ',') - 1]" doc:name="Session Variable"/>
<set-property propertyName="MULE_CORRELATION_GROUP_SIZE"
value="#[sessionVars.cnt]" doc:name="Property"/>
<collection-aggregator failOnTimeout="true" doc:name="Collection Aggregator"/>
I also tried following code But in output got only single record
<flow name="davesalesforceFlow1Tmp" doc:name="davesalesforceFlow1Tmp">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" doc:name="HTTP" path="test" contentType="text/plain" />
<sfdc:query config-ref="salesforce" doc:name="Salesforce" query="My query"/>
<collection-splitter doc:name="Collection Splitter"/>
<set-property propertyName="MULE_CORRELATION_GROUP_SIZE"
value="#[message.outboundProperties['MULE_CORRELATION_SEQUENCE']]" doc:name="Property"/>
<collection-aggregator failOnTimeout="true" doc:name="Collection Aggregator"/>
<logger message="MY PAYLOAD IS #[payload]" level="INFO" doc:name="Logger"/>
</flow>
</flow>
If you use the collection splitter and aggregator together theres no need to keep track of the count or anything.
Mule will take care of this via the MULE_CORRELATION_* header behind the scenes.
Only if you are dong for complex splits and aggregates may you need to modify these headers yourself.
<logger level="INFO" message="size before: #[payload.size()]" />
<collection-splitter />
<logger level="INFO" message="Individual item: #[payload]" />
<collection-aggregator />
<logger level="INFO" message="size after: #[payload.size()]" />

How to use AMQP with Active MQ in Mule

Hi I am working with Mule Any Point Studio. I want to define one queue name and from that queue i want to read the data using AMQP.
Its not polling the data from the Queue which i mentioned.
My Mule Flow:
<amqp:connector name="amqpConnector" doc:name="AMQP Connector" host="localhost" port="5672" username="admin" password="admin" validateConnections="true" ></amqp:connector>
<flow name="mule-ampq" doc:name="mule-ampq">
<amqp:inbound-endpoint exchangeName="AMQP.DEFAULT.EXCHANGE" queueName="newx" queueAutoDelete="true" connector-ref="amqpConnector" doc:name="AMQP" exchangeType="fanout" responseTimeout="10000"/>
<logger message="#[message.payload]" level="INFO" doc:name="Logger"/>
</flow>
I am getting the following Error:
ERROR 2014-10-16 15:54:44,452 [main] org.mule.module.launcher.DefaultArchiveDeployer:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Failed to deploy artifact 'mule-ampq', see below +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
org.mule.module.launcher.DeploymentStartException: EOFException:
at org.mule.module.launcher.application.DefaultMuleApplication.start(DefaultMuleApplication.java:143)
at org.mule.module.launcher.artifact.ArtifactWrapper$4.execute(ArtifactWrapper.java:98)
at org.mule.module.launcher.artifact.ArtifactWrapper.executeWithinArtifactClassLoader(ArtifactWrapper.java:129)
at org.mule.module.launcher.artifact.ArtifactWrapper.start(ArtifactWrapper.java:93)
at org.mule.module.launcher.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:26)
at org.mule.module.launcher.DefaultArchiveDeployer.guardedDeploy(DefaultArchiveDeployer.java:274)
at org.mule.module.launcher.DefaultArchiveDeployer.deployArtifact(DefaultArchiveDeployer.java:294)
at org.mule.module.launcher.DefaultArchiveDeployer.deployExplodedApp(DefaultArchiveDeployer.java:261)
at org.mule.module.launcher.DefaultArchiveDeployer.deployExplodedArtifact(DefaultArchiveDeployer.java:110)
at org.mule.module.launcher.DeploymentDirectoryWatcher.deployExplodedApps(DeploymentDirectoryWatcher.java:287)
at org.mule.module.launcher.DeploymentDirectoryWatcher.start(DeploymentDirectoryWatcher.java:148)
at org.mule.tooling.server.application.ApplicationDeployer.main(ApplicationDeployer.java:130)
Caused by: org.mule.retry.RetryPolicyExhaustedException: null
at org.mule.retry.policies.AbstractPolicyTemplate.execute(AbstractPolicyTemplate.java:101)
at org.mule.transport.AbstractConnector.connect(AbstractConnector.java:1621)
at org.mule.transport.AbstractConnector.start(AbstractConnector.java:424)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.mule.lifecycle.phases.DefaultLifecyclePhase.applyLifecycle(DefaultLifecyclePhase.java:237)
at org.mule.lifecycle.RegistryLifecycleManager$RegistryLifecycleCallback.onTransition(RegistryLifecycleManager.java:273)
at org.mule.lifecycle.RegistryLifecycleManager.invokePhase(RegistryLifecycleManager.java:152)
at org.mule.lifecycle.RegistryLifecycleManager.fireLifecycle(RegistryLifecycleManager.java:123)
at org.mule.registry.AbstractRegistryBroker.fireLifecycle(AbstractRegistryBroker.java:76)
at org.mule.registry.MuleRegistryHelper.fireLifecycle(MuleRegistryHelper.java:136)
at org.mule.lifecycle.MuleContextLifecycleManager$MuleContextLifecycleCallback.onTransition(MuleContextLifecycleManager.java:91)
at org.mule.lifecycle.MuleContextLifecycleManager$MuleContextLifecycleCallback.onTransition(MuleContextLifecycleManager.java:87)
at org.mule.lifecycle.MuleContextLifecycleManager.invokePhase(MuleContextLifecycleManager.java:69)
at org.mule.lifecycle.MuleContextLifecycleManager.fireLifecycle(MuleContextLifecycleManager.java:61)
at org.mule.DefaultMuleContext.start(DefaultMuleContext.java:278)
at org.mule.module.launcher.application.DefaultMuleApplication.start(DefaultMuleApplication.java:123)
... 11 more
Caused by: java.io.IOException
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:107)
at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:259)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:383)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:403)
at org.mule.transport.amqp.AmqpConnector.connectToFirstResponsiveBroker(AmqpConnector.java:443)
at org.mule.transport.amqp.AmqpConnector.doConnect(AmqpConnector.java:365)
at org.mule.transport.AbstractConnector$5.doWork(AbstractConnector.java:1561)
at org.mule.retry.policies.AbstractPolicyTemplate.execute(AbstractPolicyTemplate.java:63)
... 29 more
Caused by: com.rabbitmq.client.ShutdownSignalException: connection error; reason: java.io.EOFException
at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:67)
at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:33)
at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:328)
at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:244)
... 35 more
Caused by: java.io.EOFException
at java.io.DataInputStream.readUnsignedByte(DataInputStream.java:290)
at com.rabbitmq.client.impl.Frame.readFrom(Frame.java:104)
at com.rabbitmq.client.impl.SocketFrameHandler.readFrame(SocketFrameHandler.java:141)
at com.rabbitmq.client.impl.AMQConnection.readFrame(AMQConnection.java:402)
at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:430)
INFO 2014-10-16 15:54:44,455 [main] org.mule.module.launcher.DeploymentDirectoryWatcher:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Mule is up and kicking (every 5000ms) +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Try this example ... It contains different different exchange type used by AMQP .. For Direct Messaging you don't need to create the queue explicitly in the RabitMQ.. it will automatically created :-
<http:connector name="HttpConnector" doc:name="HTTP\HTTPS"/>
<amqp:connector name="amqpConnector" activeDeclarationsOnly="true" ackMode="MULE_AUTO" doc:name="AMQP Connector"/>
<amqp:connector name="amqpConnectorManualAck" prefetchCount="1" ackMode="MANUAL" doc:name="AMQP Connector"/>
<amqp:connector name="mandatoryAmqpConnector" mandatory="true" immediate="true" doc:name="AMQP Connector"/>
<!-- Direct Messaging -->
<amqp:connector name="amqp_config" validateConnections="true" virtualHost="/" username="guest" password="guest" doc:name="AMQP Connector"/>
<amqp:endpoint exchangeName="directEx" queueName="directQ" routingKey="routing.key" exchangeType="direct" queueDurable="true" name="amqp_direct_endpoint" responseTimeout="10000" doc:name="AMQP"/>
<!-- Direct Messaging -->
<jbossts:transaction-manager doc:name="Transaction Manager">
<property key="com.arjuna.ats.arjuna.coordinator.defaultTimeout" value="600"></property>
<property key="com.arjuna.ats.arjuna.coordinator.txReaperTimeout" value="1000000"></property>
</jbossts:transaction-manager>
<flow name="DefaultSender" doc:name="DefaultSender" >
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="1080" path="orders" doc:name="/orders" doc:description="Process HTTP reqests or responses." connector-ref="HttpConnector"/>
<set-payload value="New Message for Flow1" doc:name="Set Payload"/>
<logger message="Sending Message to Queue inhouseOrder .. Payload is #[message.payload]" level="INFO" category="DefaultSender" doc:name="Payload Logger" />
<amqp:outbound-endpoint exchange-pattern="request-response" exchangeName="directEx" exchangeType="direct" queueDurable="true" queueName="inhouseOrder" connector-ref="amqpConnector" doc:name="Dispatch to inhouseOrder" />
<byte-array-to-object-transformer doc:name="Byte Array to Object"/>
</flow>
<flow name="DefaultReceiver" doc:name="inhouseOrder" processingStrategy="synchronous" >
<amqp:inbound-endpoint queueName="inhouseOrder" connector-ref="amqpConnector" exchangeName="directEx" exchangeType="direct" queueDurable="true" doc:name="inhouseOrder" >
<amqp:transaction action="ALWAYS_BEGIN" recoverStrategy="REQUEUE" />
</amqp:inbound-endpoint>
<byte-array-to-object-transformer doc:name="Byte Array to Object"/>
<logger message="Receiving Message to Queue inhouseOrder .. Payload is #[message.payload]" level="INFO" category="DefaultReceiver" doc:name="Payload Logger" />
</flow>
<flow name="FanoutSenderExample2" doc:name="FanoutSenderExample2">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="1080" path="orders3" doc:name="/orders" doc:description="Process HTTP reqests or responses." connector-ref="HttpConnector"/>
<set-payload value="Fanout Message for Queue accounting" doc:name="Set Payload"/>
<logger message="Sending Payload in FanoutSenderExample2 #[message.payload]" level="INFO" category="FanoutSenderExample2" doc:name="Payload Logger" />
<amqp:outbound-endpoint exchangeName="back-end-processing" exchangeType="fanout" exchangeAutoDelete="false" exchangeDurable="true" queueDurable="true" queueExclusive="false" queueAutoDelete="false" exchange-pattern="one-way" connector-ref="amqpConnector" doc:name="Dispatch to back-end-processing" />
<byte-array-to-object-transformer doc:name="Byte Array to Object"/>
</flow>
<flow name="FanoutReceiverExample2" doc:name="FanoutReceiverExample2">
<amqp:inbound-endpoint exchangeName="back-end-processing" queueName="accounting" exchangeType="fanout" exchangeAutoDelete="false" exchangeDurable="true" queueDurable="true" queueExclusive="false" queueAutoDelete="false" connector-ref="amqpConnector" doc:name="back-end-processing fullfilment queue" />
<byte-array-to-object-transformer doc:name="Byte Array to Object"/>
<logger message="Payload received in FanoutReceiverExample2 is: #[payload]" level="INFO" category="FanoutReceiverExample2" doc:name="Payload Logger" />
</flow>
<!-- Direct Messaging -->
<flow name="Send_Message_Direct" doc:name="Send_Message_Direct">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="1080" doc:name="HTTP" path="orders5"/>
<set-payload value="#['im a Direct message'.getBytes()]" doc:name="Set payload for amqp message as ByteArray"/>
<amqp:outbound-endpoint responseTimeout="10000" doc:name="Send Direct Message" connector-ref="amqp_config" ref="amqp_direct_endpoint"/>
<set-payload value="#['Message Sended']" doc:name="Set payload as String"/>
<logger message="Direct message sended" level="INFO" doc:name="Logger"/>
</flow>
<flow name="Recive_Message_Direct" doc:name="Recive_Message_Direct">
<amqp:inbound-endpoint responseTimeout="10000" doc:name="Recive Direct Message" connector-ref="amqp_config" ref="amqp_direct_endpoint"/>
<byte-array-to-string-transformer doc:name="Transform bytearray message to String"/>
<logger message="I recived a direct message from AMQP: #[payload]" level="INFO" doc:name="Logger"/>
</flow>
<sub-flow name="defaultErrorHandler" doc:name="defaultErrorHandler">
<logger message="Error occurred: #[payload]" level="INFO" doc:name="Log Error"/>
<smtp:outbound-endpoint host="localhost" responseTimeout="10000" doc:name="Send Email to Operations"/>
</sub-flow>
</mule>
Reference :- Reference :- https://github.com/mulesoft/mule-transport-amqp/blob/master/GUIDE.md#mule-amqp-transport---user-guide

request-reply router is not working

I am stuck up with a problem with the request-reply router in mule. I am using the mule release 3.4.0. The request-reply is used in a fork-join pattern , i followed this article on the blog site http://blogs.mulesoft.org/aggregation-with-mule-fork-and-join-pattern/.
<request-reply>
<all enableCorrelation="ALWAYS">
<vm:outbound-endpoint path="PathA"/>
<vm:outbound-endpoint path="PathB"/>
</all>
<vm:inbound-endpoint path="FinalResponse">
<message-properties-transformer>
<add-message-property key="MULE_CORRELATION_GROUP_SIZE" value="2" />
</message-properties-transformer>
<collection-aggregator />
</vm:inbound-endpoint>
</request-reply>
The issue that i face is the processor placed after the request-reply is not reached.In mule i see 2 responses been sent to the FinalResponse vm endpoint. I tried placing my own custom aggregator in place of the collection-aggregator. But this is not reached. I am not sure how i can debug this issue. Please note that i have 2 such request-reply routers in two flows. Can someone help on this.
Adding the mule configuration. For abbrevity attaching only the parent flow and one of the child flow
ParentFlow
<flow name="ParentFlow" doc:name="ParentFlow" tracking:enable-default-events="true">
<file:inbound-endpoint path="${SourceFilePath}"
connector-ref="ParentFlowInboundConnector"
responseTimeout="10000" tracking:enable-default-events="true">
<file:filename-regex-filter pattern="${REGEX}" caseSensitive="false"/>
</file:inbound-endpoint>
<object-to-string-transformer doc:name="Object to String"/>
<message-properties-transformer
doc:name="Message Properties">
<add-message-property key="Source_System" value="XXX" />
<add-message-property key="publisherName" value="YYY" />
<add-message-property key="FlowName" value="ZZZ"/>
</message-properties-transformer>
<!-- This would store the message in the db -->
<wire-tap>
<vm:outbound-endpoint path="PERSITENCE.OUT"/>
</wire-tap>
<request-reply>
<all doc:name="Move the message to all endpoints" enableCorrelation="ALWAYS">
<vm:outbound-endpoint path="PathA"/>
<vm:outbound-endpoint path="PathB"/>
<vm:outbound-endpoint path="PathC"/>
<vm:outbound-endpoint path="PathD"/>
</all>
<vm:inbound-endpoint path="Response">
<message-properties-transformer>
<add-message-property key="MULE_CORRELATION_GROUP_SIZE" value="4" />
</message-properties-transformer>
<collection-aggregator failOnTimeout="false" doc:name="Collection Aggregator" />
</vm:inbound-endpoint>
</request-reply>
<component class="ProcessorA" />
<component class="ProcessorB" />
<exception-strategy ref="Exception Strategy" doc:name="Reference Exception Strategy"/>
</flow>
Child Flow
<flow name="PathA" doc:name="PathA">
<vm:inbound-endpoint path="PathA" >
<vm:transaction action="ALWAYS_BEGIN"/>
</vm:inbound-endpoint>
<message-properties-transformer doc:name="Message Properties">
<add-message-property key="originalFilename_processing" value="#[message.inboundProperties.originalFilename]" />
</message-properties-transformer>
<message-properties-transformer doc:name="Message Properties">
<add-message-property key="directory" value="#[message.inboundProperties.directory]" />
</message-properties-transformer>
<message-properties-transformer doc:name="Message Properties">
<add-message-property key="Destination_System" value="XXX" />
</message-properties-transformer>
<file:outbound-endpoint path="${OutPathA}" connector-ref="FileConnector_1"
tracking:enable-default-events="true"/>
<!--Send email alerts -->
<all doc:name="All" >
<processor-chain>
<message-property-filter pattern="turnOffEmail=false" caseSensitive="true" doc:name="Message Property"/>
<custom-transformer class="com.XXX.YYY.ZZZ.VelocityTemplateResolver" doc:name="Java">
<spring:property name="flowName" value="PPPP"/>
</custom-transformer>
<smtp:outbound-endpoint host="${SMTP_HOSTNAME}" port="${SMTP_PORT}" user="${SMTP_USERNAME}" password="${SMTP_PASSWORD}" to="${TO_ADDRESS}" from="${FROM_ADDRESS}" subject="${MAIL_SUBJECT}" cc="${MAIL_CC_ADDRESS}" bcc="${MAIL_BCC_ADDRESS}" responseTimeout="10000" transformer-refs="emailVelocityMessageTransformer" tracking:enable-default-events="true"/>
</processor-chain>
<processor-chain>
<message-property-filter pattern="turnOffEmail=false" caseSensitive="true" doc:name="Message Property"/>
<custom-transformer class="com.XXX.YYY.ZZZ.VelocityTemplateResolver" doc:name="Java">
<spring:property name="flowName" value="FlowName"/>
</custom-transformer>
<smtp:outbound-endpoint host="${SMTP_HOSTNAME}" port="${SMTP_PORT}" user="${SMTP_USERNAME}" password="${SMTP_PASSWORD}" to="${MAIL_TO_ADDRESS}" from="${MAIL_FROM_ADDRESS}" subject="${MAIL_SUBJECT}" cc="${MAIL_CC_ADDRESS}" bcc="${BCC_ADDRESS}" responseTimeout="10000" transformer-refs="emailVelocityMessageTransformer" tracking:enable-default-events="true"/>
</processor-chain>
<processor-chain>
<message-property-filter pattern="turnOffEmail=false" caseSensitive="true" doc:name="Message Property"/>
<custom-transformer class="com.XXX.YYY.ZZZ.VelocityTemplateResolver" doc:name="Java">
<spring:property name="flowName" value="AAAA"/>
</custom-transformer>
<smtp:outbound-endpoint host="${SMTP_HOSTNAME}" port="${SMTP_PORT}" user="${SMTP_USERNAME}" password="${SMTP_PASSWORD}" to="${MAIL_TO_ADDRESS}" from="${MAIL_FROM_ADDRESS}" subject="${MAIL_SUBJECT}" cc="${MAIL_CC_ADDRESS}" bcc="${MAIL_BCC_ADDRESS}" responseTimeout="10000" transformer-refs="emailVelocityMessageTransformer" tracking:enable-default-events="true"/>
</processor-chain>
</all>
<rollback-exception-strategy doc:name="Rollback Exception Strategy" maxRedeliveryAttempts="${MAX_REDELIVERY_ATTEMPTS}" enableNotifications="false">
<logger message="==Rollback log ===" level="INFO" doc:name="Logger"/>
</rollback-exception-strategy>
</flow>
The most likely cause of the the problem is correlation ID.
You might want to inspect the correlation ID of the messages sent out to Path A and Path B. The message received on FinalResponse VM inbound endpoint needs to have the same correlation ID, otherwise it won't be accepted as a response to the messages previously sent. In other words the request-reply will NOT accept just anything in the inbound-endpoint but just the message matching the correlation ID of the posted on outbound-endpoint with the request-reply router.
You can set the custom correlation ID using this --
<set-property propertyName="MULE_CORRELATION_ID" value="some-correlation-id" />

How to transform the JDBC reponse to HTTP response In MULE ESB

I am trying to select data from database using mule studio i have done all the jdbc connection and getting data from database.But unable to respond to client with JSON
my client is CURL client sending data to mule in JSON like this
curl -H "Content-Type: application/json" -d '{"id":"1"}' http://localhost:8081/selectdb
and created flow with below configuration i am getting response from database in my esb log but unable to pass the client my config is like this
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/current/mule-jdbc-ee.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd">
<jdbc-ee:postgresql-data-source name="PostgreSQL_Data_Source" user="youtilitydba" password="Youtility11" url="jdbc:postgresql://localhost:5432/sample" transactionIsolation="UNSPECIFIED" doc:name="PostgreSQL Data Source"/>
<jdbc-ee:connector name="Database" dataSource-ref="PostgreSQL_Data_Source" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database"/>
<flow name="selectfromdbFlow1" doc:name="selectfromdbFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="selectdb" doc:name="HTTP"/>
<json:json-to-object-transformer returnClass="java.util.Map" doc:name="JSON to Object"/>
<jdbc-ee:outbound-endpoint exchange-pattern="request-response" queryKey="SELECT" queryTimeout="-1" connector-ref="Database" doc:name="Database">
<jdbc-ee:query key="SELECT" value="select firstname,lastname,id from users where id =#[message.payload.id]"/>
</jdbc-ee:outbound-endpoint>
<logger message="message before set httpresponse #[payload]" level="INFO" doc:name="Logger"/>
<response>
<logger message="after expression #[payload]" level="INFO" doc:name="Logger"/>
</response>
<response>
<expression-transformer expression="#[payload]" doc:name="Expression"/>
</response>
</flow></mule>
and i logged it twice but same message logging but unable to send to client my logs like this
INFO 2013-11-29 12:57:12,589 [[selectfromdb].connector.http.mule.default.receiver.02] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'Database.dispatcher.1260873373'. Object is: EEJdbcMessageDispatcher
INFO 2013-11-29 12:57:12,589 [[selectfromdb].connector.http.mule.default.receiver.02] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'Database.dispatcher.1260873373'. Object is: EEJdbcMessageDispatcher
INFO 2013-11-29 12:57:12,637 [[selectfromdb].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: message before set httpresponse [{lastname=ff, firstname=ff, id=5}]
INFO 2013-11-29 12:57:12,639 [[selectfromdb].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: after expression [{lastname=ff, firstname=ff, id=5}]
but not geting from client side
tried with setpayload,echo,httpresponsebuilder,expression-transfomer also but i am unable to get this
After the query you have to use an Object to JSON Transformer then add an HTTP Response Builder with the following properties: contentType=application/json and status=200.
Here is an example:
<flow name="DB-Read-TestFlow1" doc:name="DB-Read-TestFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="selectdb" doc:name="HTTP"/>
<json:json-to-object-transformer returnClass="java.util.Map" doc:name="JSON to Object"/>
<jdbc-ee:outbound-endpoint exchange-pattern="request-response" queryKey="SELECT" queryTimeout="-1" connector-ref="Database" doc:name="Database">
<jdbc-ee:query key="SELECT" value="select firstname,lastname,id from users where id =#[message.payload.id]"/>
</jdbc-ee:outbound-endpoint>
<logger message="message before set httpresponse #[payload]" level="INFO" doc:name="Logger"/>
<response>
<logger message="after expression #[payload]" level="INFO" doc:name="Logger"/>
</response>
<json:object-to-json-transformer doc:name="Object to JSON"/>
<response>
<http:response-builder status="200" contentType="application/json" doc:name="HTTP Response Builder"/>
</response>
</flow>
You can directly use <http:response-builder/> at the end with your status code and set you message as payload
Something like the following :-
<http:response-builder status="200" contentType="application/json" doc:name="HTTP Response Builder">
<set-payload value="Your Message" />
</http:response-builder>

Mule throttling on a backend service

I have a back end service that I need to throttle access to. I'm trying to use the approach described here: http://blogs.mulesoft.org/synchronous-and-asynchronous-throttling-2/
I started with a simple pass through flow that receives a SOAP request and forwards it. When I hit this using the SOAPUI utility, I get the expected response in a second or two.
<http:connector name="httpConnector" doc:name="HTTP\HTTPS">
<receiver-threading-profile maxThreadsActive="1" maxBufferSize="100" />
</http:connector>
<jms:activemq-connector name="amqConnector" brokerURL="tcp://localhost:61616" specification="1.1" doc:name="AMQ" />
<flow name="Flow1" processingStrategy="synchronous" doc:name="Flow1">
<http:inbound-endpoint exchange-pattern="request-response"
host="localhost" port="8088" path="test" doc:name="HTTP"
mimeType="text/xml" encoding="UTF-8" connector-ref="httpConnector"/>
<http:outbound-endpoint
address="http://dnbdirect-api.dnb.com/DnBAPI-11"
exchange-pattern="request-response" doc:name="HTTP" mimeType="text/xml"/>
</flow>
If I then move the outbound call to a separate flow and add in the request-reply block, the behavior changes. I get no response back (nor do I get the "After queue" message from the logger) and SOAPUI eventually times out.
<http:connector name="httpConnector" doc:name="HTTP\HTTPS">
<receiver-threading-profile maxThreadsActive="1" maxBufferSize="100" />
</http:connector>
<jms:activemq-connector name="amqConnector" brokerURL="tcp://localhost:61616" specification="1.1" doc:name="AMQ" />
<flow name="Flow1" processingStrategy="synchronous" doc:name="Flow1">
<http:inbound-endpoint exchange-pattern="request-response"
host="localhost" port="8088" path="test" doc:name="HTTP"
mimeType="text/xml" encoding="UTF-8" connector-ref="httpConnector"/>
<message-properties-transformer doc:name="Message Properties">
<add-message-property key="AMQ_SCHEDULED_DELAY" value="5000"/>
</message-properties-transformer>
<logger message="Before queue" level="INFO"/>
<request-reply>
<jms:outbound-endpoint queue="request" connector-ref="amqConnector"></jms:outbound-endpoint>
<jms:inbound-endpoint queue="response" connector-ref="amqConnector"></jms:inbound-endpoint>
</request-reply>
<logger message="After queue" level="INFO"/>
</flow>
<flow name="flow2" doc:name="Flow2">
<jms:inbound-endpoint queue="request" connector-ref="amqConnector" doc:name="JMS"/>
<http:outbound-endpoint
address="http://dnbdirect-api.dnb.com/DnBAPI-11"
exchange-pattern="request-response" doc:name="HTTP" mimeType="text/xml" />
</flow>
The throttling behavior works as I see the delays if I pull out the call to the back end service. But I can't get it to work with the service call there.
What am I missing?
I found that the message's payload will be "ArrayList" after "request-reply".
so i add a java component to split it, then the result will be corrected.
#Override
public Object onCall(MuleEventContext eventContext) throws Exception {
MuleMessage message = eventContext.getMessage();
//int groupSize = message.getCorrelationGroupSize();
//System.out.println("############# correlationGroupSize: " + groupSize);
Object payload = message.getPayload();
if (payload != null && payload instanceof ArrayList) {
//message.setPayload(((ArrayList)payload).get(0));
return ((ArrayList)payload).get(0);
}
return message.getPayload();
}
the completed flow is:
<message-properties-transformer doc:name="Message Properties">
<add-message-property key="AMQ_SCHEDULED_DELAY" value="10000"/>
</message-properties-transformer>
<request-reply storePrefix="mainFlow">
<jms:outbound-endpoint queue="request" connector-ref="amqConnector" doc:name="JMS"></jms:outbound-endpoint>
<jms:inbound-endpoint queue="response" connector-ref="amqConnector" doc:name="JMS"></jms:inbound-endpoint>
</request-reply>
<component class="com.neusoft.fx.JmsMessageTransformer" doc:name="Java"/>
<message-properties-transformer doc:name="Set Content Type">
<delete-message-property key="Content-type" />
<add-message-property key="Content-Type" value="text/xml"/>
</message-properties-transformer>
<logger message="----- LOGGER ----- after #[groovy:message.toString()]" level="INFO" doc:name="Logger" />
</flow>
Try adding the following before the HTTP outbound endpoint in flow2:
<copy-properties propertyName="MULE_*"/>