我正在尝试设置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
键。我已经确认客户端正在将正确的映射条目添加到标头中,并且在将其发送到网络之前一直没有损坏。关于可能出什么问题的任何指示?
附言hornetq是2.2.9。最终,libstomp是svn的最新修订版(rev 90-http://svn.codehaus.org/stomp/trunk/c/),它是用apr 1.4.6编译的;全部在Win-7上运行
最佳答案
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协议将此保留为与实现有关的约定。