I get messages from one jms queue. I'm using mule requester component but how can i give that jms queue path in resources option ?
Please assist me., Thanks.,
Pass in the queue in URL format:
<mulerequester:request config-ref="Mule_Requester" resource="jms://input?connector=AMQConnector1" doc:name="Request a message from a queue" />
The Mule config will be :
-<mulerequester:config name="Mule_Requester" doc:name="Mule Requester"/> <jms:activemq-connector name="Active_MQ" brokerURL="tcp://localhost:61616" specification="1.1" doc:name="Active MQ"/> <flow name="QueueRequester" doc:name="QueueRequester"> <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="fetch" doc:name="HTTP"/> <mulerequester:request config-ref="Mule_Requester" resource="jms://input" doc:name="Request a message from a queue" /> <logger message="Payload from JMS message: #[payload]" level="WARN" doc:name="Logger"/> </flow>
Now suppose there is a JMS queue named input from where we need to fetch data in our flow on we hit the url : `http://localhost:8081/fetch '.
Related
I checked several previous discussions but couldnt find the answer.
I am trying to achieve synchronous communicaiton using JMS back-channel (http://www.whishworks.com/blog/synchronous-communication-using-jms-back-channel). Apart from the things mentioned in that site, I need to filter out the message from the inbound queue based on a dynamic Id.
Following are my mule flows:
<flow name="serverFlow" >
<jms:inbound-endpoint doc:name="REQUEST" queue="REQUEST.QUEUE" connector-ref="jmsConnector">
<jms:selector expression="MULE_CORRELATION_ID='#[sessionVars.myCorrelationId]'"/>
</jms:inbound-endpoint>
<set-payload value="#[payload] + Hello World from Receiver" doc:name="Set Payload" />
<jms:outbound-endpoint doc:name="REPLY" queue="REPLY.QUEUE" connector-ref="jmsConnector" />
</flow>
<flow name="mainFlow" >
<http:listener config-ref="HTTP_Listener_Configuration" path="/jms" allowedMethods="GET" doc:name="HTTP"/>
<set-session-variable variableName="myCorrelationId" value="#[System.currentTimeMillis().toString()]" doc:name="Set Correlation ID"/>
<set-payload value="New message sent from Mule - mainFlow at #[new Date()]" doc:name="Set Message"/>
<set-property propertyName="MULE_CORRELATION_ID" value="#[sessionVars.myCorrelationId]" doc:name="Property"/>
<request-reply doc:name="Request-Reply">
<jms:outbound-endpoint doc:name="REQUEST" connector-ref="jmsConnector" queue="REQUEST.QUEUE"/>
<jms:inbound-endpoint doc:name="REPLY" connector-ref="jmsConnector" queue="REPLY.QUEUE"/>
</request-reply>
<logger message="Reply to sender: #[message]" level="WARN" doc:name="Logger" />
</flow>
If I try a static value like "<jms:selector expression="MULE_CORRELATION_ID='12345'"/>", it works. But if I try a dynamic ID using MEL, its not working. The MEL inside the jms selector expression is not working. The message stays at the queue as Unread. I used logs to see what the MULE_CORRELATION_ID is while being set at mainFlow and found the same value is set in the message that is UNREAD in the queue. So, I guess nothing is wrong in the way the MULE_CORRELATION_ID is set. The only problem is that MEL is not working within jms:selector.
Could you please help how to get MEL working within JMS selector?
Thank you very much.
MEL is working fine in the selector but its usage is very limited. When the JMS selector is created, there's no in-flight event available to Mule so none of the event-bound data (including session) is available.
To select a very particular message, you need to use a JMS message requester, constructed with the desired selector, like:
jms://REQUEST.QUEUE?selector=MULE_CORRELATION_ID%3D'#[sessionVars.myCorrelationId]'
Here is the working solution based on David's suggestion. I am using wmq here (not jms).
<mulerequester:config name="Mule_Requester" doc:name="Mule Requester"/>
<flow name="mainFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/test" allowedMethods="GET" doc:name="HTTP"/>
<set-payload value="My Message" doc:name="Set Message"/>
<set-property propertyName="JMSCorrelationID" value="12345" doc:name="Property"/>
<set-session-variable variableName="myCorrelationId" value="ID:313233343500000000000000000000000000000000000000" doc:name="Set Correlation ID"/>
<!--313233343500000000000000000000000000000000000000 is the MQMD CorrelationId for 12345. This is set by IBM MQ -->
<logger message="The Message to REQUEST QUEUE: #[message]" level="WARN" doc:name="Logger"/>
<wmq:outbound-endpoint queue="REQUEST.QUEUE" connector-ref="wmqConnector" doc:name="OUT"/>
<mulerequester:request config-ref="Mule_Requester" resource="wmq://REPLY.QUEUE?selector=JMSCorrelationID%3D'#[sessionVars.myCorrelationId]'" doc:name="Mule Requester" timeout="120000"/>
<logger message="Final Response: #[message]" level="WARN" doc:name="Logger"/>
</flow>
Please note, I manually moved the message from Request queue to Reply queue using MQVE for my testing. In real time, it will be done by another program.
I'm having a random problem with amqp components in Mule.
This is the scenario:
I set a global AMQP connector to be used for both Mule Flows
<amqp:connector
name="amqpLocalhostConnector"
host="${amqp.host}"
port="${amqp.port}"
fallbackAddresses="${amqp.fallbackAddresses}"
virtualHost="${amqp.virtualHost}"
username="${amqp.username}"
password="${amqp.password}"
ackMode="MANUAL"
prefetchCount="1" />
This flows sends a notification to RabbitMQ
<flow
name="notifyRabbitMQ"
doc:name="notifyRabbitMQ">
<!-- Set the payload with an ID from an element in a database -->
<set-payload
doc:name="Set Payload"
value="123abc"/>
<!-- Send the ID into an amqp message to RabbitMQ -->
<amqp:outbound-endpoint
exchangeName="exchange"
routingKey="file.id"
connector-ref="amqpLocalhostConnector">
</amqp:outbound-endpoint>
</flow>
This flow gets the notification from the RabbitMQ queue and then process it.
<flow
name="processNotification"
doc:name="processNotification"
processingStrategy="synchronous">
<amqp:inbound-endpoint
queueName="files"
connector-ref="amqpLocalhostConnector" />
<byte-array-to-string-transformer doc:name="Message to String (ID)"/>
<set-payload
value="#[app.registry.customFileService.findFile(payload)]"
doc:name="Get File" />
<logger message="SUCCESS!" level="INFO" doc:name="Logger"/>
<amqp:acknowledge-message />
</flow>
When I run the project, sometimes it works fine and sometimes it throws the following error:
ERROR 2015-07-17 12:37:47,620 [[rabbit_notification].amqpLocalhostConnector.receiver.01] org.mule.transport.amqp.AmqpMessageReceiver$AmqpMessageRouterWork: Impossible to route: org.mule.transport.amqp.AmqpMessage#43cac8[consumerTag=amq.ctag-jASX98hPWb7UUiIVHLOeEQ,envelope=Envelope(deliveryTag=2, redeliver=false, exchange=exchange, routingKey=file.id),body={53,53,97,57,50,49,52,98,50,50,50,57,101,56,56,51,55,101,98,54,102,100,56,53},properties=#contentHeader(content-type=null, content-encoding=UTF-8, headers={MULE_SESSION=rO0ABXNyACNvcmcubXVsZS5zZXNzaW9uLkRlZmF1bHRNdWxlU2Vzc2lvbi7rdtEW7GGKAwAEWgAFdmFsaWRMAA1mbG93Q29uc3RydWN0dAAmTG9yZy9tdWxlL2FwaS9jb25zdHJ1Y3QvRmxvd0NvbnN0cnVjdDtMAAJpZHQAEkxqYXZhL2xhbmcvU3RyaW5nO0wAD3NlY3VyaXR5Q29udGV4dHQAJ0xvcmcvbXVsZS9hcGkvc2VjdXJpdHkvU2VjdXJpdHlDb250ZXh0O3hwAXB0ACRjNjI4Zjc0Ny0yYzk5LTExZTUtYjI3YS1lMWM4ZmJjNTUzY2Fwc3IAJWphdmEudXRpbC5Db2xsZWN0aW9ucyRTeW5jaHJvbml6ZWRNYXAbc/kJS0s5ewMAAkwAAW10AA9MamF2YS91dGlsL01hcDtMAAVtdXRleHQAEkxqYXZhL2xhbmcvT2JqZWN0O3hwc3IAJG9yZy5tdWxlLnV0aWwuQ2FzZUluc2Vuc2l0aXZlSGFzaE1hcJ3R2e9nRc4AAwAAeHB3DD9AAAAAAAAQAAAAAHhxAH4ACXh4, MULE_ENCODING=UTF-8, MULE_ROOT_MESSAGE_ID=c628f745-2c99-11e5-b27a-e1c8fbc553ca, MULE_ENDPOINT=amqp://exchange}, delivery-mode=2, priority=0, correlation-id=null, reply-to=null, expiration=null, message-id=c628f745-2c99-11e5-b27a-e1c8fbc553ca, timestamp=Fri Jul 17 12:37:47 ART 2015, type=null, user-id=null, app-id=null, cluster-id=null)]
Does anyone knows why this could be happening?
Thanks in advance.
Can a queue consume from a topic directly in a publish-subscribe mode.Can somebody provide pointers on this. I am using websphere MQ as a JMS broker.What should be the Mule configuration for setting this up.
Mule Configuration
testTopic10 is the topic name
testQueue10 is the queue name
<!-- Publisher Flow -->
<flow name="PublisherFlow" doc:name="PublisherFlow">
<file:inbound-endpoint path="c:\retryin" responseTimeout="10000" doc:name="File"/>
<object-to-string-transformer doc:name="Object to String"/>
<jms:outbound-endpoint topic="testTopic10" doc:name="JMS" connector-ref="WMQ_Pub_Topic_Connector"/>
</flow>
<!-- Transfer from topic to Queue -->
<flow name="SubscriberFlowQueueTransfer" doc:name="SubscriberFlowQueueTransfer">
<jms:inbound-endpoint topic="testTopic10" connector-ref="WMQ_Pub_Topic_Connector" doc:name="JMS">
</jms:inbound-endpoint>
<logger message="Entered Subscriber Queue transfer" level="INFO" doc:name="Logger"/>
<jms:outbound-endpoint queue="testQueue10" connector-ref="WMQ_Sub_Queue_Connector" doc:name="JMS">
</jms:outbound-endpoint>
</flow>
<!-- Subscriber Flow -->
<flow name="SubscriberFlowQueue" doc:name="SubscriberFlowQueue">
<jms:inbound-endpoint queue="testQueue10" connector-ref="WMQ_Sub_Queue_Connector" doc:name="JMS">
<jms:transaction action="ALWAYS_BEGIN" timeout="3000"/>
</jms:inbound-endpoint>
<logger message="Entered subscriber flow" level="INFO" doc:name="Logger"/>
<ftp:outbound-endpoint host="XXX.XXX.XX.XX" port="21" path="path" user="test" password="test123" responseTimeout="10000" doc:name="FTP"/>
<rollback-exception-strategy doc:name="Rollback Exception Strategy" enableNotifications="false"/>
</flow>
Connector Configurations
<jms:connector name="WMQ_Pub_Topic_Connector" specification="1.1" validateConnections="true" connectionFactory-ref="WebSphereMQConnectionFactory" doc:name="JMS" durable="true" clientId="mule-server-01" persistentDelivery="true" maxRedelivery="5">
<reconnect-forever frequency="5000" />
</jms:connector>
<jms:connector name="WMQ_Sub_Queue_Connector" specification="1.1" validateConnections="true" connectionFactory-ref="WebSphereMQConnectionFactory" doc:name="JMS" durable="true" clientId="mule-server-01" persistentDelivery="true" maxRedelivery="5">
<receiver-threading-profile maxThreadsActive="1"/>
<reconnect-forever/>
</jms:connector>
It's pretty straightforward, you can take a look at WebSphere MQ transpor documentation and WebShphere MQ example. But basically you need to:
Configure a WMQ connector
<wmq:connector name="wmqConnector" hostName="${wmq.host}" port="${wmq.port}" queueManager="${wmq.queue.manager}" username="${wmq.username}" password="${wmq.password}" />
Create a flow with an endpoint
<flow name="MessageProcessor">
<wmq:inbound-endpoint connector-ref="wmqConnector" queue="topic.in">
...
</flow>
Add MQ jars to MULE_HOME/lib/user
com.ibm.mq.jar
com.ibm.mqetclient.jar (if using remote XA transactions)
com.ibm.mq.jmqi.jar
com.ibm.mqjms.jar
dhbcore.jar
When i make a call to to soap web service using the soap component in Mule. The message properties context is lost. I understand a Mule enricher component can be used but not sure on the usage. Below you will find my test mule code
<spring:beans>
<spring:bean id="myWebServiceImpl" class="com.xxx.xxx.service.MyWebServiceImpl">
</spring:bean>
</spring:beans>
<custom-transformer class="com.xxx.xxx.service.TestTransformer" name="Java" doc:name="Java"/>
<flow name="testwebserviceFlow1" doc:name="testwebserviceFlow1">
<file:inbound-endpoint path="c:\landing" responseTimeout="10000" doc:name="File"/>
<object-to-string-transformer doc:name="Object to String"/>
<http:outbound-endpoint exchange-pattern="request-response" method="POST" address="http://localhost:28081/MyWebService" responseTimeout="100000" doc:name="HTTP" >
<cxf:jaxws-client operation="helloWorld" serviceClass="com.xxx.xxx.service.MyWebService" enableMuleSoapHeaders="true" doc:name="SOAP"/>
</http:outbound-endpoint>
<transformer ref="Java" doc:name="Transformer Reference"/>
<logger level="INFO" doc:name="Logger"/>
</flow>
<flow name="MyWebServiceFlow" doc:name="MyWebServiceFlow">
<http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:28081/MyWebService?wsdl" doc:name="HTTP" responseTimeout="100000">
<cxf:jaxws-service serviceClass="com.xxx.xxx.service.MyWebService" doc:name="SOAP"/>
</http:inbound-endpoint>
<component doc:name="MyWebService">
<spring-object bean="myWebServiceImpl"/>
</component>
</flow>
Yes, you can use an enricher to preserve your original message and put the return value of the web service into a variable. It works like this:
<enricher source="#[payload]" target="#[variable:myVal]">
<http:outbound-endpoint exchange-pattern="request-response" method="POST" address="http://localhost:28081/MyWebService" responseTimeout="100000" doc:name="HTTP" >
<cxf:jaxws-client operation="helloWorld" serviceClass="com.xxx.xxx.service.MyWebService" enableMuleSoapHeaders="true" doc:name="SOAP"/>
</http:outbound-endpoint>
</enricher>
You can then later access the variable like this:
<logger message="#[variable:myVal]" level="INFO"/>
If you just want to call the web service and ignore any return values, you can also do that asynchronously by putting the http outbound inside <async></async> tags instead of the enricher.
I am trying implement deadLetterQueue on UntilSuccessful for JDBC Connector. I would like to send the payload to a queue(DeadLetterQueue) when UntilSuccessful fails after trying no of times as configured. I referred following links
http://blogs.mulesoft.org/meet-until-successful-store-and-forward-for-mule/
Where in the application would you define the vm:endpoint for a dlqEndpoint-ref defined in an until-successful scope?
Below is my code snippet
<vm:endpoint exchange-pattern="one-way" path="dlqChannel" name="VM" doc:name="VM"/>
Above line is my global element
<flow...> .... <until-successful objectStore-ref="objectStore" deadLetterQueue-ref="dlqChannel" maxRetries="5" secondsBetweenRetries="60" doc:name="Until Successful" failureExpression="exception-type:java.sql.SQLException">
<jdbc-ee:outbound-endpoint exchange-pattern="request-response" queryKey="Insert Query" queryTimeout="-1" connector-ref="Database" doc:name="Database"/>
</until-successful>....</flow>
<flow name="Flow2" doc:name="Flow2">
<endpoint ref="dlqChannel" />
<logger message="DEAD DEAD DEAD LETTER LETTER LETTER #[message]" level="INFO" doc:name="Logger"/>
</flow>
At this line <endpoint ref="dlqChannel" /> I am getting compile error says "Reference to unknown global element:dlqChannel"
Can any one suggest a best way to achieve this scenario.
Thanks,
Kalyan
Your endpoint is called 'VM' not 'dlqChannel'. Change either the name to dlqChannel or point it to VM.
This issue is resolved.
Below is my code snippet.
<vm:endpoint exchange-pattern="one-way" path="dlq" name="dlqChannel" doc:name="VM"/>
Above line is vm global element
<flow...> ... <until-successful objectStore-ref="objectStore" deadLetterQueue-ref="dlqChannel" maxRetries="2" secondsBetweenRetries="10" doc:name="Until Successful" failureExpression="exception-type:java.sql.SQLException">
<jdbc-ee:outbound-endpoint exchange-pattern="request-response" queryKey="Insert Query" queryTimeout="-1" connector-ref="Database" doc:name="Database"/>
</until-successful>
....
</flow>
<flow name="Flow2" doc:name="Flow2">
<vm:inbound-endpoint exchange-pattern="one-way" path="dlq" doc:name="VM"/>
<logger message="DEAD DEAD DEAD LETTER LETTER LETTER #[message.payload]" level="INFO" doc:name="Logger"/>
</flow>
Based on "deadLetterQueue-ref" in UntilSuccessful, payload goes to vm:inbound-endpoint(vm://dlq) as defined in the vm global endpoint.
As Seba correctly points out, your error is due to a wrong name/ref. As for how to implement the deadLetterQueue, you need an inbound endpoint. So in Flow2, change the endpoint to <inbound-endpoint ref="dlqChannel" />.