与hornetq服务器通信时,STOMP标头中的目的地错误

时间:2012-12-20 09:40:25

标签: java hornetq stomp

我正在尝试设置一个C客户端与hornetq jms服务器通信。我在C端使用带有libstomp的STOMP接受器。

我的C客户端代码只是来自libstomp页面的this example,并且密码和目标队列名称已更改(可以从java客户端访问的有效队列)。

这是我运行时得到的结果:

Connecting......OK
Sending connect message.OK
Reading Response.Response: CONNECTED,
OK
Sending Subscribe.OK
Sending Message.OK
Reading Response.Response: ERROR, org.hornetq.core.protocol.stomp.StompException:     Client must set destination or id head
er to a SUBSCRIBE command
        at     org.hornetq.core.protocol.stomp.StompProtocolManager.onSubscribe(StompProtocolManager.java:    339)
        at     org.hornetq.core.protocol.stomp.StompProtocolManager.handleBuffer(StompProtocolManager.java:196)
        at     org.hornetq.core.protocol.stomp.StompConnection.bufferReceived(StompConnection.java:279)
        at     org.hornetq.core.remoting.server.impl.RemotingServiceImpl$DelegatingBufferHandler.bufferRec    eived(RemotingServ
iceImpl.java:512)
        at     org.hornetq.core.remoting.impl.netty.HornetQChannelHandler.messageReceived(HornetQChannelHa    ndler.java:73)
        at     org.jboss.netty.channel.SimpleChannelHandler.handleUpstream(SimpleChannelHandler.java:100)
        at     org.jboss.netty.channel.StaticChannelPipeline.sendUpstream(StaticChannelPipeline.java:372)
        at     org.jboss.netty.channel.StaticChannelPipeline.sendUpstream(StaticChannelPipeline.java:367)
        at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:274)
        at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:261)
        at org.jboss.netty.channel.socket.oio.OioWorker.run(OioWorker.java:100)
        at     org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
        at     org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:44)
        at     org.jboss.netty.util.VirtualExecutorService$ChildExecutorRunnable.run(VirtualExecutorServic    e.java:181)
        at     java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at     java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
OK
Sending Disconnect.OK
Disconnecting...OK

简而言之 - 我从服务器获得此异常:

ERROR, org.hornetq.core.protocol.stomp.StompException: Client must set destination or id header to a SUBSCRIBE command

在示例的第92行,我们设置目的地:

apr_hash_set(frame.headers, "destination", APR_HASH_KEY_STRING, "/queue/FOO.BAR");

尽管如此,当消息到达服务器并解析标题时,我得到一个地图ation -> /queue/FOO.BAR,但它正在寻找destination密钥。我已经确认客户端正在向标头添加正确的映射条目,并且它一直没有损坏,直到将其发送到网络。

关于可能出错的指示?

P.S。 hornetq是2.2.9.Final,libstomp是svn(rev 90 - http://svn.codehaus.org/stomp/trunk/c/)的最新版本,它是用apr 1.4.6编译的;全部在Win-7上运行

1 个答案:

答案 0 :(得分:1)

2.2.9是一个非常古老的HornetQ版本。您应该使用2.2.14或最新的2.3.beta重试。我只是看了一下HornetQ master的git中的代码,目的地正在处理

请参阅https://github.com/hornetq/hornetq/blob/master/hornetq-server/src/main/java/org/hornetq/core/protocol/stomp/VersionedStompFrameHandler.java#L254

上的onSubscribe()

FWIW,在HornetQ中,点.用作目标的除数(您的代码使用斜杠/)。 STOMP协议将此作为依赖于实现的约定。