【发布时间】:2011-12-05 08:28:19
【问题描述】:
每当新的 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 文件放在我的 lib 文件夹中用于 ActiveMQ。
这是我的路线目前的样子:
<?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 服务器本身有问题?
【问题讨论】:
-
是在运行这个骆驼路线的应用程序的lib目录中的camel-jms依赖吗?这确实是它需要的地方。
标签: java jms apache-camel