I’m attempting to use a Camel route to send a POST message to a PHP script whenever a new JMS message arrives in a given queue. I’ve gotten that working, but right now the POST message is missing the JMS message body, and I’m getting the following error in my ActiveMQ logs:
2011-10-10 17:46:39,961 | ERROR | Caused by: [org.apache.camel.RuntimeCamelException -
java.lang.ClassCastException: org.apache.camel.impl.DefaultMessage cannot be cast to
org.apache.camel.component.jms.JmsMessage] |
org.apache.camel.component.jms.EndpointMessageListener |
DefaultMessageListenerContainer-1
org.apache.camel.RuntimeCamelException: java.lang.ClassCastException:
org.apache.camel.impl.DefaultMessage cannot be cast to
org.apache.camel.component.jms.JmsMessage
I have included camel-jms dependency in my pom.xml file. I’m using Camel 2.4.0, and placed the camel-jms jar file in my lib folder for ActiveMQ.
This is what my route currently looks like:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<route autoStartup="true" inheritErrorHandler="true" id="route2" xmlns:ns2="http://camel.apache.org/schema/web" xmlns="http://camel.apache.org/schema/spring">
<from uri="activemq:topic:topic_name"/>
<setBody inheritErrorHandler="true" id="setBody2">
<simple>name=${body}</simple>
</setBody>
<setHeader headerName="Content-Type" inheritErrorHandler="true" id="setHeader3">
<constant>application/x-www-form-urlencoded;</constant>
</setHeader>
<setHeader headerName="CamelHttpMethod" inheritErrorHandler="true" id="setHeader4">
<constant>POST</constant>
</setHeader>
<to uri="http://path/to/process.php" inheritErrorHandler="true" id="to2"/>
</route>
Am I missing something in my route configuration? Or is there something wrong with the ActiveMQ server itself?
There was a bug in Camel about this. You can fix this by upgrading Camel or use a newer AMQ which have a more recent Camel version.