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