JBoss 7.4.0内嵌Artemis Broker中STOMP协议无法正常工作
JBoss 7.4.0内嵌Artemis Broker无法接收Python STOMP连接问题
问题背景
我们运行JBoss 7.4.0,内嵌的Artemis Broker在JBoss内部应用及外部Java客户端中均能正常使用。现需支持另一团队通过Python(使用STOMP协议)向队列发送消息,但该功能在JBoss内嵌Artemis Broker中无法正常工作,而在独立Artemis Broker中可正常运行。
已完成的配置操作
1. Socket绑定与远程接收器配置
添加了新的socket绑定和远程接收器:
<socket-binding name="external-messaging-stomp" port="61613"/> ... <remote-acceptor name="stomp-acceptor" socket-binding="external-messaging-stomp"> <param name="protocols" value="STOMP"/> </remote-acceptor>
2. 新增STOMP协议模块
最初JBoss日志提示协议未找到,经排查发现JBoss未包含STOMP协议的JAR包,因此添加了对应的模块(路径:modules\system\layers\base\org\apache\activemq\artemis\protocol\stomp\main),使用了与JBoss提供的Artemis JAR版本匹配的红帽版stomp jar,模块配置如下:
<module name="org.apache.activemq.artemis.protocol.stomp" xmlns="urn:jboss:module:1.9"> <resources> <resource-root path="artemis-stomp-protocol-2.16.0.redhat-00022.jar"/> </resources> <dependencies> <!-- required to load ActiveMQ protocol SPI --> <module name="org.apache.activemq.artemis"/> <module name="io.netty"/> </dependencies> </module>
同时更新了现有modules\system\layers\base\org\apache\activemq\artemis\main\module.xml,添加:
<module name="org.apache.activemq.artemis.protocol.stomp" services="import" optional="true"/>
配置验证日志
配置后JBoss日志显示已成功加载STOMP协议并启动对应的接收器:
2022-08-19 13:27:07,702 INFO [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 78) AMQ221043: Protocol module found: [artemis-stomp-protocol]. Adding protocol support for: STOMP 2022-08-19 13:27:11,040 INFO [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 78) AMQ221020: Started NIO Acceptor at 127.0.0.1:61613 for protocols [STOMP]
测试情况
Python测试脚本
import logging import time import sys import stomp logging.basicConfig(level=logging.DEBUG) hosts = [('127.0.0.1', 61613)] print("Creating connection") conn = stomp.Connection(host_and_ports=hosts) print("Connecting") conn.connect('myUserId', 'myPassword', wait=True)
异常现象
- 脚本连接时一直挂起,调试日志显示已发送连接帧:
DEBUG:stomp.py:Sending frame: [b'STOMP', b'\n', b'accept-version:1.2\n', b'host:127.0.0.1\n', b'login:myUserId\n', b'passcode:myPassword\n', b'\n', b'\x00']
- JBoss侧无任何日志输出,即使开启Artemis的TRACE日志也未看到连接或握手相关内容。
- Wireshark抓包显示:Python脚本发送连接帧后,端口61613返回了TCP ACK,但JBoss/Artemis未回复任何内容,连接一直处于打开状态。
- 对比测试:独立Artemis Broker中使用相同端口配置时一切正常,抓包显示独立Artemis在收到连接帧的ACK后会返回STOMP连接成功帧。
求助需求
我们已为此问题困扰多日,寻求解决思路。
内容的提问来源于stack exchange,提问作者Todd Johnson
相关产品推荐
相关产品推荐

