繁体   English   中英

Wildfly / JBoss - STOMP 协议在嵌入式 Artemis 代理中不起作用

[英]Wildfly / JBoss - STOMP protocol not working in embedded Artemis broker

我们正在运行 JBoss 7.4.0。 我们正在运行嵌入式 Artemis 代理,并且在 JBoss 和外部 Java 客户端中运行的应用程序中成功使用它,没有任何问题。

我们有一个新要求,允许另一个组将消息放入队列。 他们使用的是使用 STOMP 协议的 Python。 我无法在 JBoss 嵌入式 Artemis 代理中实现此功能。 它在 Artemis 独立代理中运行良好。

对于 JBoss 配置和设置,我添加了一个新的套接字绑定和远程接受器,如下所示:

<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>

我在 JBoss 日志中收到有关未找到协议的错误。 我做了一些研究,看起来 JBoss 不包括用于 STOMP 协议的 JARs。 我添加了一个模块(modules\system\layers\base\org\apache\activemq\artemis\protocol\stomp\main)。 I pulled the redhat version of the stomp jar with a matching version number and build number as the rest of the JBoss provided Artemis jars. 这是模块。xml:

<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 看到这些日志:

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 得到了它。 JBoss / Artemis 根本不会发回任何东西,连接将保持打开并永远连接。

正如我提到的,我使用相同的端口号设置了独立的 Artemis,一切正常。 我嗅探了那些流量,最初看起来都一样。 但是对于独立的 Artemis,在连接帧数据包的 ACK 之后,Artemis 会发回一个 STOMP 帧,指示它已连接。

这几天我一直在用头撞墙。 因此,如果有人有任何想法,我很想听听他们的意见。

谢谢! 托德

多亏了 ehsavoie,我才得以完成这项工作。 他指出 JBoss EAP 移除了 STOMP 支持,但 Wildfly 有。 我查看了 Wildfly 版本 (23.0.0),它是我们 JBoss EAP 版本 (7.4.0) 的基础。 我在为 STOMP 协议设置模块时犯了错误。 在 module.xml 中,我错过了 JBoss 日志记录的依赖关系。 添加后,一切正常。

因此,对于任何试图让 STOMP 在 JBoss EAP 中工作的人来说,这些都是步骤......

  1. 查看 Artemis 模块中的 jars 并获取版本号和内部版本号。
  2. 从 Red Hat Maven 存储库获取 artemis-stomp-protocol.jar 的正确版本和构建
  3. 通过将 jar 复制到新目录 (modules\system\layers\base\org\apache\activemq\artemis\protocol\stomp\main) 并创建 module.xml 来为 STOMP 创建一个新模块,如下所示。
  4. 更新 artemis 的主模块.xml (modules\system\layers\base\org\apache\activemq\artemis\main\module.xml) 以包含 STOMP 模块作为可选模块,如下所示。
  5. 在您的配置中创建一个套接字绑定和远程接受器。

这适用于 EAP 7.4.0。 如果您正在运行不同的版本,请使用适当的模块。xml 作为模板。 更好的是,下载相应版本的 Wildfly 并查看它是如何设置的。 这是模块。xml 我最终得到了 STOMP 模块:

<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="org.jboss.logging"/>
        <module name="io.netty"/>
    </dependencies>
</module>

这是您需要添加到现有 artemis 模块的行。xml:

    <dependencies>
        …
        <module name="org.apache.activemq.artemis.protocol.stomp" services="import" optional="true"/>
        …
    </dependencies>

这是更改 JBoss 配置(stanalone.xml 等)为端口# 61613 添加套接字绑定:

    <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
        …
        <socket-binding name="external-messaging-stomp" port="61613"/>
        …
    </socket-binding-group>

最后是配置为使用 STOMP 并侦听端口 61613 的远程接受器:

        <subsystem xmlns="urn:jboss:domain:messaging-activemq:13.0">
            <server name="default">
                …
                <remote-acceptor name="stomp-acceptor" socket-binding="external-messaging-stomp">
                    <param name="protocols" value="STOMP"/>
                </remote-acceptor>
                …
            </server>
        </subsystem>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM