Artemis STOMP消息没有传递到OPENWIRE JMS客户端



我们正在尝试从activemq5升级。x升级到最新的Artemis(2.17),但是我们的一个应用程序给我们带来了麻烦。

该应用程序是一个使用STOMP的旧PHP web应用程序。它创建一个临时响应队列,向目标发送消息,然后等待响应。在activemq5下。x,这工作得很好(多年来),但在Artemis中,请求只是挂起直到超时。

目标是基于JMS API和Openwire的Java应用程序。我们的大多数应用程序都是这样的,彼此之间没有任何交流问题……只有这一个PHP web应用程序是有问题的,它似乎是我们唯一基于STOMP的东西。

我们在隔离状态下运行一个事务,并且启用了Artemis STOMP调试,下面是我们看到的:

07:47:42,180 STOMP(/10.0.0.5:40618, f985f04d): IN << StompFrame[command=CONNECT, headers={login=<appid>, passcode=<app-password>}]
07:47:42,196 STOMP(/10.0.0.5:40618, f985f04d):OUT >> StompFrame[command=CONNECTED, headers={session=f985f04d}]
07:47:42,203 STOMP(/10.0.0.5:40618, f985f04d): IN << StompFrame[command=SUBSCRIBE, headers={ack=client, destination=/temp-queue/Reply-604379ee2f900, activemq.prefetchSize=1}]
07:47:42,235 STOMP(/10.0.0.5:40618, f985f04d): IN << StompFrame[command=SEND, headers={expires=1615035162000, destination=/queue/target, content-type=text/plain, reply-to=/temp-queue/Reply-604379ee2f900}, body=<--- message text---> body-bytes=[<--- message bytes --->, size=0]
07:48:42,247 STOMP(/10.0.0.5:40618, f985f04d): IN << StompFrame[command=DISCONNECT, headers={}]

问题的核心似乎是来自"SEND"上面所示的操作永远不会到达接收器。我们已经验证了接收器是在线的,并且它响应使用JMS和Openwire连接的其他客户端-但是这个STOMP消息没有被路由到目的地。

如果我们关闭Artemis并恢复到activemq5。X,应用程序运行正常。

我们使用默认配置:

<acceptors>
<!-- useEpoll means: it will use Netty epoll if you are on a system (Linux) that supports it -->
<!-- amqpCredits: The number of credits sent to AMQP producers -->
<!-- amqpLowCredits: The server will send the # credits specified at amqpCredits at this low mark -->
<!-- amqpDuplicateDetection: If you are not using duplicate detection, set this to false
as duplicate detection requires applicationProperties to be parsed on the server. -->
<!-- amqpMinLargeMessageSize: Determines how many bytes are considered large, so we start using files to hold their data.
default: 102400, -1 would mean to disable large mesasge control -->
<!-- Note: If an acceptor needs to be compatible with HornetQ and/or Artemis 1.x clients add
"anycastPrefix=jms.queue.;multicastPrefix=jms.topic." to the acceptor url.
See https://issues.apache.org/jira/browse/ARTEMIS-1644 for more information. -->

<!-- Acceptor for every supported protocol -->
<acceptor name="artemis">tcp://0.0.0.0:61616?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;amqpMinLargeMessageSize=102400;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300;amqpDuplicateDetection=true</acceptor>
<!-- AMQP Acceptor.  Listens on default AMQP port for AMQP traffic.-->
<acceptor name="amqp">tcp://0.0.0.0:5672?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=AMQP;useEpoll=true;amqpCredits=1000;amqpLowCredits=300;amqpMinLargeMessageSize=102400;amqpDuplicateDetection=true</acceptor>
<!-- STOMP Acceptor. -->
<acceptor name="stomp">tcp://0.0.0.0:61613?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=STOMP;useEpoll=true</acceptor>
<!-- HornetQ Compatibility Acceptor.  Enables HornetQ Core and STOMP for legacy HornetQ clients. -->
<acceptor name="hornetq">tcp://0.0.0.0:5445?anycastPrefix=jms.queue.;multicastPrefix=jms.topic.;protocols=HORNETQ,STOMP;useEpoll=true</acceptor>
<!-- MQTT Acceptor -->
<acceptor name="mqtt">tcp://0.0.0.0:1883?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=MQTT;useEpoll=true</acceptor>
</acceptors>

我们是否需要一些神奇的配置来将这些STOMP消息路由到正确的目的地?

第一个问题是消息被发送到的destination。如activemq5中所述。x STOMP文档的/queue/前缀使用的SEND帧的destination头被自动剥离。然而,在ActiveMQ Artemis中,这需要通过ActiveMQ Artemis STOMP文档中讨论的anycastPrefix参数显式配置,例如:

<acceptor name="stomp">tcp://0.0.0.0:61613?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=STOMP;useEpoll=true;anycastPrefix=/queue/;multicastPrefix=/topic/</acceptor>

为了完整性,这里也配置了multicastPrefix

一旦配置,那么您的消息将按预期发送到target

然而,我认为在SUBSCRIBE帧的destination标头以及SEND帧的reply-to标头上使用的/temp-queue/前缀仍然会有问题。ActiveMQ 5。x也特别对待这些(尽管我找不到关于它的文档)。ActiveMQ Artemis不会为这些资源创建临时资源,但我认为您仍然可以获得您想要的行为,因为代理可以自动创建和自动删除资源,就像它们是临时的一样。这里需要配置的主要内容是前缀,例如:

<acceptor name="stomp">tcp://0.0.0.0:61613?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=STOMP;useEpoll=true;anycastPrefix=/queue/,/temp-queue/;multicastPrefix=/topic/,/temp-topic/</acceptor>

由于您的Stomp客户端使用/temp-queue/指定reply-to标头,而您的OpenWire客户端使用此标头,那么您也需要更改OpenWireacceptor,例如:

<acceptor name="artemis">tcp://0.0.0.0:61616?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;amqpMinLargeMessageSize=102400;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300;amqpDuplicateDetection=true;anycastPrefix=/temp-queue/;multicastPrefix=/temp-topic/</acceptor>

我已经打开了Artemis -3164来实现一个前缀,用于在ActiveMQ Artemis中标识临时资源。

最新更新