STOMP消息未到达队列

时间:2014-07-07 17:44:12

标签: websocket activemq stomp

我正在尝试使用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消息的方式配置我的路由。有什么提示吗?

2 个答案:

答案 0 :(得分:1)

如果没有更多信息,说起来有点难,但我的第一个猜测是,在消息有机会被写入套接字或被ActiveMQ读取之前,stomp客户端连接正在关闭。您可能需要考虑通过向出站帧添加请求ID来对队列执行阻塞,并等待Broker向您发送响应帧。这将确保在关闭连接之前发布您的消息。

如何执行阻止放置取决于您使用的客户端,因此您需要查看文档以了解正确的方法是什么。通常会有同步发送方法或客户端添加&#39; receipt&#39;标题到框架,然后执行阻止接收,直到您使用正确匹配的&#39; receipt-id&#39;返回RECEIPT框架。报头中。

答案 1 :(得分:0)

您是否正在连接ActiveMQ服务器上的stomp端口? 如在&#34; transportConnector&#34;下的config(activemq.xml)中所见。 stomp需要在默认配置的端口61613上连接。

将Node.js与&#34; stomp-client&#34;一起使用和localhost上的默认ActiveMQ服务器:

var my_client = new Stomp('127.0.0.1', 61613, 'admin', 'admin');
相关问题