How to use polling with wmq-inbound connector in mule? - mule

Sample example is :
<flow name="testFlow">
<poll doc:name="Poll">
<fixed-frequency-scheduler frequency="10000" startDelay="10"/>
<wmq:inbound-endpoint queue="${mq.ssl.mvs.queue1}" connector-ref="wMQConfig1" doc:name="WMQ"/>
</poll>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</flow>
I get following error:
org.mule.module.launcher.DeploymentInitException: SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'wmq:inbound-endpoint'. One of '{"http://www.mulesoft.org/schema/mule/core":abstract-poll-override, "http://www.mulesoft.org/schema/mule/core":abstract-message-processor, "http://www.mulesoft.org/schema/mule/core":abstract-outbound-endpoint, "http://www.mulesoft.org/schema/mule/core":abstract-mixed-content-message-processor}' is expected. at org.mule.module.launcher.application.DefaultMuleApplication.init(DefaultMuleApplication.java:205)
~[mule-module-launcher-3.8.0.jar:3.8.0] at org.mule.module.launcher.artifact.ArtifactWrapper$2.execute(ArtifactWrapper.java:63)
~[mule-module-launcher-3.8.0.jar:3.8.0] at org.mule.module.launcher.artifact.ArtifactWrapper.executeWithinArtifactClassLoader(ArtifactWrapper.java:136)
~[mule-module-launcher-3.8.0.jar:3.8.0] at org.mule.module.launcher.artifact.ArtifactWrapper.init(ArtifactWrapper.java:58) ~[mule-module-launcher-3.8.0.jar:3.8.0] at org.mule.module.launcher.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:25)
~[mule-module-launcher-3.8.0.jar:3.8.0] at org.mule.module.launcher.DefaultArchiveDeployer.guardedDeploy(DefaultArchiveDeployer.java:324)
~[mule-module-launcher-3.8.0.jar:3.8.0] at org.mule.module.launcher.DefaultArchiveDeployer.deployArtifact(DefaultArchiveDeployer.java:345)
~[mule-module-launcher-3.8.0.jar:3.8.0] at org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:163)
~[mule-module-launcher-3.8.0.jar:3.8.0] at org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:268)
~[mule-module-launcher-3.8.0.jar:3.8.0] at org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:83)
~[mule-module-launcher-3.8.0.jar:3.8.0] at org.mule.module.launcher.DeploymentDirectoryWatcher.deployPackedApps(DeploymentDirectoryWatcher.java:275)
~[mule-module-launcher-3.8.0.jar:3.8.0] at org.mule.module.launcher.DeploymentDirectoryWatcher.start(DeploymentDirectoryWatcher.java:150)
~[mule-module-launcher-3.8.0.jar:3.8.0] at org.mule.module.launcher.MuleDeploymentService.start(MuleDeploymentService.java:104)
~[mule-module-launcher-3.8.0.jar:3.8.0] at org.mule.module.launcher.MuleContainer.start(MuleContainer.java:170)
~[mule-module-launcher-3.8.0.jar:3.8.0] at org.mule.tooling.server.application.ApplicationDeployer.main(ApplicationDeployer.java:15)
~[tooling-support-3.8.0.jar:?]

You are using a Poll wrapped wmq:inbound-endpoint as your message source. If you are reading from the WebSphereMQ you will need to change this to a wmq:outbound-endpoint component else move it to the process flow section.

Related

Mule reuse request-reply (same JMS Queues)

My flow is necessary to use the component request-reply twice, but when I try to do the following problem:
<flow name="myprojectFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<request-reply doc:name="RR1">
<jms:outbound-endpoint queue="req_queue" doc:name="JMS" connector-ref="Active_MQ">
<jms:transaction action="ALWAYS_BEGIN"/>
</jms:outbound-endpoint>
<jms:inbound-endpoint queue="rep_queue" doc:name="JMS" connector-ref="Active_MQ">
<jms:transaction action="ALWAYS_BEGIN"/>
</jms:inbound-endpoint>
</request-reply>
<request-reply doc:name="RR2">
<jms:outbound-endpoint queue="req_queue" doc:name="JMS" connector-ref="Active_MQ">
<jms:transaction action="ALWAYS_BEGIN"/>
</jms:outbound-endpoint>
<jms:inbound-endpoint queue="rep_queue" doc:name="JMS" connector-ref="Active_MQ">
<jms:transaction action="ALWAYS_BEGIN"/>
</jms:inbound-endpoint>
</request-reply>
</flow>
Another system receives a message from req_queue and send into rep_queue.
Error:
ERROR 2015-10-07 19:48:41,703 [main] org.mule.module.launcher.application.DefaultMuleApplication: null
org.mule.api.transport.ConnectorException: There is already a listener registered on this connector on endpointUri: jms://rep_queue. Connector that caused exception is: ActiveMQJmsConnector
{
name=Active_MQ
lifecycle=start
this=75361cf6
numberOfConcurrentTransactedReceivers=4
createMultipleTransactedReceivers=true
connected=true
supportedProtocols=[jms]
serviceOverrides=<none>
}
at org.mule.transport.AbstractConnector.registerListener(AbstractConnector.java:1258) ~[mule-core-3.7.0.jar:3.7.0]
at org.mule.endpoint.DefaultInboundEndpoint.start(DefaultInboundEndpoint.java:104) ~[mule-core-3.7.0.jar:3.7.0]
at org.mule.routing.requestreply.SimpleAsyncRequestReplyRequester.start(SimpleAsyncRequestReplyRequester.java:87) ~[mule-core-3.7.0.jar:3.7.0]
at org.mule.processor.chain.AbstractMessageProcessorChain.start(AbstractMessageProcessorChain.java:102) ~[mule-core-3.7.0.jar:3.7.0]
at org.mule.construct.AbstractFlowConstruct.startIfStartable(AbstractFlowConstruct.java:325) ~[mule-core-3.7.0.jar:3.7.0]
at org.mule.construct.AbstractPipeline.doStart(AbstractPipeline.java:351) ~[mule-core-3.7.0.jar:3.7.0]
at org.mule.construct.Flow.doStart(Flow.java:90) ~[mule-core-3.7.0.jar:3.7.0]
at org.mule.construct.AbstractFlowConstruct$2.onTransition(AbstractFlowConstruct.java:136) ~[mule-core-3.7.0.jar:3.7.0]
How can I use the request-reply with the same JMS queue twice in one flow?
Are your sure about JMS queues your pointing? I can see your sending message to "req_queue" and pointing to the "rep_queue" to receive message. you will never get the message there from "rep_queue". I have modified slightly and worked from me. let me know if it's not fulfill your requirement...
<flow name="myprojectFlow">
<http:listener config-ref="HTTP_Listener_Configuration1" path="/" doc:name="HTTP"/>
<set-payload doc:name="Set Payload" value="Hi"/>
<request-reply doc:name="RR1">
<jms:outbound-endpoint queue="req_queue" doc:name="JMS" connector-ref="Active_MQ">
<jms:transaction action="ALWAYS_BEGIN"/>
</jms:outbound-endpoint>
<jms:inbound-endpoint queue="req_queue" doc:name="JMS" connector-ref="Active_MQ">
<jms:transaction action="ALWAYS_BEGIN"/>
</jms:inbound-endpoint>
</request-reply>
<logger message="---- payload ---#[payload]" level="INFO" doc:name="Logger"/>
<request-reply doc:name="RR2">
<jms:outbound-endpoint queue="req_queue1" doc:name="JMS" connector-ref="Active_MQ">
<jms:transaction action="ALWAYS_BEGIN"/>
</jms:outbound-endpoint>
<jms:inbound-endpoint queue="req_queue1" doc:name="JMS" connector-ref="Active_MQ">
<jms:transaction action="ALWAYS_BEGIN"/>
</jms:inbound-endpoint>
</request-reply>
<logger message="---- payload1 ---#[payload]" level="INFO" doc:name="Logger"/>

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

Mule - Message Splitter and Response Aggregation for a synchronous flow

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>

mule send email as an attachment

My below code perfectly send email as an attachment, but the problem is
1) payload is copying to the mail body. I want mail to be sent only as an attachment, don't want to include attachment in body part of the mail.
2) email triggers twice always. I have given thread count as 1. Not sure from where the second event is triggering.
Code:
<mule xmlns:email="http://www.mulesoft.org/schema/mule/email" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:context="http://www.springframework.org/schema/context" xmlns:smtp="http://www.mulesoft.org/schema/mule/smtp" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" 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/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.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/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/smtp http://www.mulesoft.org/schema/mule/smtp/current/mule-smtp.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/email http://www.mulesoft.org/schema/mule/email/current/mule-email.xsd">
<spring:beans>
<context:property-placeholder location="accord.properties"/>
<spring:bean id="transmission" class="com.creativeworld.service.InvokeTransmission"/>
</spring:beans>
<quartz:connector name="ABCQuartz" validateConnections="true" doc:name="ABC Quartz">
<quartz:factory-property key="org.quartz.scheduler.instanceName" value="ABC_XYZKReport"/>
<quartz:factory-property key="org.quartz.threadPool.class" value="org.quartz.simpl.SimpleThreadPool"/>
<quartz:factory-property key="org.quartz.threadPool.threadCount" value="1"/>
<quartz:factory-property key="org.quartz.scheduler.rmi.proxy" value="false"/>
<quartz:factory-property key="org.quartz.scheduler.rmi.export" value="false"/>
</quartz:connector>
<smtp:connector name="ABCSMTP" validateConnections="true" doc:name="SMTP" subject="ABC_XYZK Report"/>
<flow name="flow1" doc:name="flow1" processingStrategy="synchronous">
<quartz:inbound-endpoint jobName="ABCQuartz" repeatInterval="180000" responseTimeout="10000" connector-ref="ABCQuartz" doc:name="ABC XYZK">
<quartz:event-generator-job groupName="creativeworld" jobGroupName="creativeworld">
<quartz:payload>Creative World Quartz Scheduler.</quartz:payload>
</quartz:event-generator-job>
</quartz:inbound-endpoint>
<scripting:component doc:name="Python">
<scripting:script engine="jython" file="ABC_XYZK.py"/>
</scripting:component>
<set-session-variable variableName="outputfilepath" value="${OUTPUT_FILE}${FILE_NAME}-#[server.dateTime.format('${DATETIME_FORMAT}')]${FILE_TYPE}" doc:name="File Name" />
<set-payload value="${COMMAND_PATH}#[' ']${DB_NAME}${OUTPUT_FILE}${URL}" doc:name="Transmission Commands"/>
<set-payload value="#[message.payload]#[' -outputpath ']#[outputfilepath]" doc:name="Output Config"/>
<invoke object-ref="transmission" method="invoke" methodArgumentTypes="java.lang.String" methodArguments="#[payload]" name="transmissionAPI"/>
<vm:outbound-endpoint exchange-pattern="one-way" path="smtp" doc:name="VM"/>
</flow>
<flow name="smtp" doc:name="smtp" processingStrategy="synchronous">
<vm:inbound-endpoint exchange-pattern="one-way" path="smtp" doc:name="VM"/>
<scripting:component doc:name="Groovy">
<scripting:script engine="Groovy"><![CDATA[new File(sessionVars['outputfilepath']).text]]></scripting:script>
</scripting:component>
<set-attachment attachmentName="${FILE_NAME}-#[server.dateTime.format('${DATETIME_FORMAT}')]${FILE_TYPE}" value="#[payload]" contentType="text/plain" doc:name="ABC_XYZK Report"/>
<smtp:outbound-endpoint host="mailrelay.ad.corp.local" responseTimeout="10000" doc:name="SMTP" connector-ref="ABCSMTP" mimeType="text/plain" from="mymailid#mycompany.com" subject="ABC_XYZK" to="mymailid#mycompany.com">
<!-- <email:email-to-string-transformer/> -->
</smtp:outbound-endpoint>
</flow>
Simple solution :- If you don't want the same payload in the mail body simply put <set-payload value="Hi this is the mail content " doc:name="Output Config"/> just after <set-attachment > tag with the content you like to have as mail body eg :-
<set-attachment attachmentName="${FILE_NAME}-#[server.dateTime.format('${DATETIME_FORMAT}')]${FILE_TYPE}" value="#[payload]" contentType="text/plain" doc:name="ABC_XYZK Report"/>
<set-payload value="Hi this is the mail content " doc:name="Output Config"/>
<smtp:outbound-endpoint host="mailrelay.ad.corp.local" responseTimeout="10000" doc:name="SMTP" connector-ref="ABCSMTP" mimeType="text/plain" from="mymailid#mycompany.com" subject="ABC_XYZK" to="mymailid#mycompany.com">
<!-- <email:email-to-string-transformer/> -->
</smtp:outbound-endpoint>
The payload you set after attachment will be in your mail body

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>