【发布时间】:2014-08-28 06:57:43
【问题描述】:
我正在尝试使用 STOMP 和 ActiveMQ 将客户端输入浏览器的消息发送到队列。从我在控制台中获得的读数来看,STOMP 连接是成功的。我没有收到错误并且正在使用该行:
stompClient.send("/queue/testQSource", {}, JSON.stringify({ 'name': name }));
在我的 index.html 中这样做。但是,当我输入浏览器后检查ActiveMQ控制台时,testQSource并没有添加。我是否使用正确的 STOMP 语法来实现这一点?除了 STOMP 源之外,我是否需要在 HTML 文件的顶部添加任何源?
这里用骆驼路线实例化队列:
<from uri="jms:queue:testQSource"/>
<to uri="securityBean"/>
<log message="Routing message from testQSource to testQDestination queue with data ${body}"/>
<to uri="jms:queue:testQDestination"/>
<to uri="activationBean"/>
<log message="message: ${body}"/>
编辑
我现在收到一条消息,但收到以下警告:
WARN : org.apache.camel.component.jms.JmsBinding - Cannot determine specific JmsMessage type to use from body class. Will use generic JmsMessage. Body class: hello.HelloMessage. If you want to send a POJO then your class might need to implement java.io.Serializable, or you can force a specific type by setting the jmsMessageType option on the JMS endpoint.
我相信这是因为 STOMP 消息与队列和/或路由所期望的形式不同。但是,我不确定如何以允许我使用 STOMP 消息的方式配置我的路由。有什么建议吗?
【问题讨论】:
-
骆驼路由配置中的 URI 包含 JMS,但 STOMP 不同。你试过用 stomp 代替 jms 吗?