Impossible to route: org.mule.transport.amqp.AmqpMessage - rabbitmq

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.

Related

what is wrong with Jersey class in below Mule flow?

In the following mule flow, I have implemented Jersey class for REST web service with VM endpoints.
<flow name="APIKeyLoadFlow" doc:name="APIKeyLoadFlow"
initialState="started">
<http:inbound-endpoint exchange-pattern="request-response"
address="${api.load.invoke.url}" doc:name="HTTP"
responseTimeout="${apikey.http.responsetimeout}" />
<logger message="Start Of APIKeyLoadFlow -#[payload]" level="INFO"
doc:name="ENTRY_LOG" />
<request-reply timeout="300000" >
<vm:outbound-endpoint connector-ref="VM_Connector"
exchange-pattern="one-way" path="APIKeyLoadRequest">
</vm:outbound-endpoint>
<vm:inbound-endpoint connector-ref="VM_Connector"
exchange-pattern="one-way" path="APIKeyLoadResponse">
</vm:inbound-endpoint>
</request-reply>
<logger message="End of APIKeyLoadFlow" level="INFO" doc:name="EXIT_LOG" />
<catch-exception-strategy doc:name="Catch Exception Strategy">
<logger level="WARN" doc:name="Exception_Log"
message="Exception in ApiKeyFlow #[System.getProperty('line.separator')] Error Description = #[exception.getMessage()]" />
</catch-exception-strategy>
</flow>
<flow name="ApiKeyLoadRestServiceFlow" doc:name="ApiKeyLoadRestServiceFlow">
<vm:inbound-endpoint exchange-pattern="one-way"
path="APIKeyLoadRequest" doc:name="APIKey_Load_Request">
</vm:inbound-endpoint>
<logger message="Start of ApiKeyLoadRestServiceFlow -#[payload]" level="INFO"
doc:name="ENTRY_LOG" />
<jersey:resources doc:name="REST">
<component class="com.elexon.bmrs.apikey.service.impl.ApiKeyLoadImpl" />
</jersey:resources>
<logger message="End of ApiKeyLoadRestServiceFlow" level="INFO"
doc:name="EXIT_LOG" />
<vm:outbound-endpoint exchange-pattern="one-way"
path="APIKeyLoadResponse" doc:name="APIKey_Load_Response">
</vm:outbound-endpoint>
But i am getting below exception while running the request? Kindly let me what is the issue in the implemented flow?
INFO 2015-12-08 13:09:59,792 [[apikey_load_phase3].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: Start Of APIKeyLoadFlow -org.apache.commons.httpclient.ContentLengthInputStream#1517f14
INFO 2015-12-08 13:09:59,813 [[apikey_load_phase3].connector.http.mule.default.receiver.02] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'VM_Connector.dispatcher.25489136'. Object is: VMMessageDispatcher
INFO 2015-12-08 13:09:59,813 [[apikey_load_phase3].connector.http.mule.default.receiver.02] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'VM_Connector.dispatcher.25489136'. Object is: VMMessageDispatcher
INFO 2015-12-08 13:09:59,830 [[apikey_load_phase3].ApiKeyLoadRestServiceFlow.stage1.02] org.mule.api.processor.LoggerMessageProcessor: Start of ApiKeyLoadRestServiceFlow -org.apache.commons.httpclient.ContentLengthInputStream#1517f14
ERROR 2015-12-08 13:09:59,833 [[apikey_load_phase3].ApiKeyLoadRestServiceFlow.stage1.02] org.mule.exception.DefaultMessagingExceptionStrategy:
Message : Failed to invoke JerseyResourcesComponent{ApiKeyLoadRestServiceFlow.component.14630019}. Component that caused exception is: JerseyResourcesComponent{ApiKeyLoadRestServiceFlow.component.14630019}. Message payload is of type: ContentLengthInputStream
Code : MULE_ERROR--2
Exception stack is:
1. null (java.lang.NullPointerException)
org.mule.module.jersey.JerseyResourcesComponent:116 (null)
2. Failed to invoke JerseyResourcesComponent{ApiKeyLoadRestServiceFlow.component.14630019}. Component that caused exception is: JerseyResourcesComponent{ApiKeyLoadRestServiceFlow.component.14630019}. Message payload is of type: ContentLengthInputStream (org.mule.component.ComponentException)
org.mule.component.AbstractComponent:144 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/component/ComponentException.html)
Root Exception stack trace:
java.lang.NullPointerException
at org.mule.module.jersey.JerseyResourcesComponent.doInvoke(JerseyResourcesComponent.java:116)
at org.mule.component.AbstractComponent.invokeInternal(AbstractComponent.java:122)
at org.mule.component.AbstractComponent.access$000(AbstractComponent.java:57)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
The Jersey component needs to be bound to an http endpoint, so not sure it can work behind a VM endpoint as all the http header and request information will be lost when passing a transport barrier etc. You could try copying the headers from inbound to outbound before the vm call, but still not sure this will work.

How to configure mule requester?

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 '.

How to use Mule Expression in JMS:selector

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.

How to implement deadLetterQueue for JDBC Connector Using Until Successful

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" />.

How to kick off a mule flow to read messages from a JMS queue using an HTTP endpoint

I basically have two flows :
HTTP Inbound endpoint receives batch XML, splits to individual pieces and stages it to a JMS queue.
Reads the staged XMLs from the JMS queue and processes the messages.
I need to control the execution of flow 2 above using a Rest call (i.e) flow 2 should run only when an HTTP inbound call is received. I am using Mule version 3.2.2
Here are the flows:
<flow name="flow-stage-input">
<http:inbound-endpoint host="localhost"
port= "8082"
path= "test/order"
exchange-pattern= "request-response"
>
</http:inbound-endpoint>
<object-to-string-transformer></object-to-string-transformer>
<splitter evaluator="xpath" expression="//Test/TestNode" enableCorrelation="ALWAYS"/>
<custom-transformer class="org.testing.transformers.DocumentToString"></custom-transformer>
<pooled-component>
<spring-object bean="receiver"></spring-object>
</pooled-component>
<!-- DECIDE SUCCESS OR FAILURE -->
<choice>
<when expression="//Test/TestNode" evaluator="xpath">
<jms:outbound-endpoint queue="stagingQueue" exchange-pattern="one-way" connector-ref="jmsConnector" />
</when>
<otherwise>
<logger message="Skipped staging message due to errors" level="ERROR" />
</otherwise>
</choice>
<collection-aggregator></collection-aggregator>
<custom-transformer class="org.testing.transformers.ListOfStringsToString"></custom-transformer>
<!-- RESPONSE SENT BACK TO CALLER -->
</flow>
<flow name="flow-process-jms-input" >
<jms:inbound-endpoint queue="stagingQueue" exchange-pattern="one-way" connector-ref="jmsConnector" />
<pooled-component>
<spring-object bean="processor"></spring-object>
</pooled-component>
<!-- DECIDE SUCCESS OR FAILURE -->
<choice>
<when expression="//ErrorCondition/Path" evaluator="xpath">
<jms:outbound-endpoint queue="errorQueue" exchange-pattern="one-way" connector-ref="jmsConnector" />
</when>
<otherwise>
<logger message="Message processed successfully" level="ERROR" />
</otherwise>
</choice>
</flow>
Use a Groovy script in flow 2 to request one JMS message from the queue using:
muleContext.client.request("jms://stagingQueue", 0)
This will return null if the queue was empty otherwise a Mule message containing the JMS message.