Apache Camel:DefaultMessage 无法转换为 JmsMessage
每当新的 JMS 消息到达给定队列时,我尝试使用 Camel 路由将 POST 消息发送到 PHP 脚本。我已经完成了该工作,但现在 POST 消息缺少 JMS 消息正文,并且我在 ActiveMQ 日志中收到以下错误:
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
我已在 pom.xml 文件中包含camel-jms 依赖项。我使用的是Camel 2.4.0,并将camel-jms jar 文件放置在ActiveMQ 的lib 文件夹中。
这就是我的路线当前的样子:
<?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>
我的路线配置中是否缺少某些内容?还是ActiveMQ服务器本身有问题?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Camel 中有一个关于此的错误。您可以通过升级 Camel 或使用具有更新 Camel 版本的较新 AMQ 来解决此问题。
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.