Wildfly 18 JMS 执行原因 'Abrupt close on Remoting connection'

Wildfly 18 JMS execution causes 'Abrupt close on Remoting connection'

我在本地有两个 Wildfly 18 实例 运行:n1n2。我希望实例 n2 使用实例 n1 生成的消息,以便采取措施实现 HA 方案。 看完RH EAP docs, 我做了以下事情:

1- 在 n2 上定义了一个公开的 JMS 队列。此外,我在 ActiveMQ 子模块中添加了安全设置和远程工厂:

[...]
<server name="default">
   <security-setting name="#">
       <role name="guest" send="true" consume="true" create-non-durable-queue="true" delete-non-durable-queue="true"/>
   </security-setting>
[...]
   <jms-queue name="testQueue" entries="queue/test java:jboss/exported/jms/queue/test"/>
   <connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector" ha="true" block-on-acknowledge="true" reconnect-attempts="-1"/>
</server>
[...]

2- 我通过 TCPPING 配置 JGroups 并使用初始节点列表加入集群,以实现集群发现:

[...]
<protocol type="org.jgroups.protocols.TCPPING">
   <property name="initial_hosts">127.0.0.1[8600]</property>
     <property name="port_range">0</property>
 </protocol>
[...]

3- 然后我启动了这两个实例,我在应用程序日志中收到以下消息:

(Thread-12 (ActiveMQ-server-org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl@7124120f)) AMQ221027: Bridge ClusterConnectionBridge@c6997b5 [name=$.artemis.internal.sf.my-cluster.f3561996-f354-11ea-83cc-4c32759d60cf, queue=QueueImpl[name=$.artemis.internal.sf.my-cluster.f3561996-f354-11ea-83cc-4c32759d60cf, postOffice=PostOfficeImpl [server=ActiveMQServerImpl::serverUUID=c9af42f1-f354-11ea-8e25-4c32759d60cf], temp=false]@2747e684 targetConnector=ServerLocatorImpl (identity=(Cluster-connection-bridge::ClusterConnectionBridge@c6997b5 [name=$.artemis.internal.sf.my-cluster.f3561996-f354-11ea-83cc-4c32759d60cf, queue=QueueImpl[name=$.artemis.internal.sf.my-cluster.f3561996-f354-11ea-83cc-4c32759d60cf, postOffice=PostOfficeImpl [server=ActiveMQServerImpl::serverUUID=c9af42f1-f354-11ea-8e25-4c32759d60cf], temp=false]@2747e684 targetConnector=ServerLocatorImpl [initialConnectors=[TransportConfiguration(name=http-connector, factory=org-apache-activemq-artemis-core-remoting-impl-netty-NettyConnectorFactory) ?httpUpgradeEndpoint=http-acceptor&activemqServerName=default&httpUpgradeEnabled=true&port=<port_number>&host=localhost], discoveryGroupConfiguration=null]]::ClusterConnectionImpl@1775690639[nodeUUID=c9af42f1-f354-11ea-8e25-4c32759d60cf, connector=TransportConfiguration(name=http-connector, factory=org-apache-activemq-artemis-core-remoting-impl-netty-NettyConnectorFactory) ?httpUpgradeEndpoint=http-acceptor&activemqServerName=default&httpUpgradeEnabled=true&port=8323&host=localhost, address=jms, server=ActiveMQServerImpl::serverUUID=c9af42f1-f354-11ea-8e25-4c32759d60cf])) [initialConnectors=[TransportConfiguration(name=http-connector, factory=org-apache-activemq-artemis-core-remoting-impl-netty-NettyConnectorFactory) ?httpUpgradeEndpoint=http-acceptor&activemqServerName=default&httpUpgradeEnabled=true&port=<port_number>&host=localhost], discoveryGroupConfiguration=null]] is connected

但是当我尝试使用以下 JNDI conf 将消息从 n1 发送到 n2 时,

java.naming.factory.initial = org.wildfly.naming.client.WildFlyInitialContextFactory
java.naming.provider.url = remote://localhost:8323
java.naming.security.principal = ***
java.naming.security.credentials = ***
Connection Factory JNDI name = jms/RemoteConnectionFactory
Queue JNDI name = jms/queue/test

...我在一定的超时(~30 秒)后收到此错误:

javax.naming.CommunicationException: WFNAM00018: Failed to connect to remote host [Root exception is java.io.IOException: JBREM000202: Abrupt close on Remoting connection 4ba0f2c1 to localhost/127.0.0.1:8323 of endpoint (anonymous)

我尝试使用一个简单的 JMS 客户端 (https://plugins.jetbrains.com/plugin/10949-jms-messenger) 连接到同一个队列,我实际上能够连接,因为我至少遇到了以下错误:

ERROR [com.my.app.Receiver] (Thread-14 (ActiveMQ-client-global-threads)) Unknown message: ActiveMQMessage[ID:5f71e993-f377-11ea-acfc-169f02eb582c]:PERSISTENT/ClientMessageImpl[messageID=442, durable=true, address=jms.queue.test,userID=5f71e993-f377-11ea-acfc-169f02eb582c,properties=TypedProperties[__AMQ_CID=5f684ca0-f377-11ea-acfc-169f02eb582c,_AMQ_ROUTING_TYPE=1]]

你能告诉我哪里出了问题并解释为什么会这样吗?非常感谢

我通过处理 Wildfly 和 JNDI 配置解决了这个问题。尽管错误消息非常通用,但至少在我的情况下,以下 Wildfly 配置:

<subsystem xmlns="urn:jboss:domain:messaging-activemq:8.0">
  <server name="default">
     <http-acceptor name="http-acceptor-throughput" http-listener="messaging">
                <param name="batch-delay" value="50"/>
                <param name="direct-deliver" value="false"/>
            </http-acceptor>
     ...
     <http-connector name="http-connector-throughput" socket-binding="messaging-throughput" endpoint="http-acceptor-throughput">
                <param name="batch-delay" value="50"/>
            </http-connector>
    ...
    <jms-queue name="test" entries="queue/test java:jboss/exported/jms/test"/>
    <broadcast-group name="bg-group1" jgroups-cluster="activemq-cluster" broadcast-period="5000" connectors="http-connector"/>
    <discovery-group name="dg-group1" jgroups-cluster="activemq-cluster"/>        
    ...
    <connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector" ha="true" block-on-acknowledge="true" reconnect-attempts="-1"/> 
</subsystem>
...
<subsystem xmlns="urn:jboss:domain:remoting:4.0">
   <http-connector name="messaging-remoting-connector" connector-ref="messaging-http" security-realm="ApplicationRealm"/>
</subsystem>
...
<socket-binding-group ... >
   ...
   <socket-binding name="messaging" port="8323"/>
   <socket-binding name="messaging-throughput" port="8324"/>
   ...
</socket-binding-group>

使用以下 JNDI 配置:

java.naming.factory.initial = org.wildfly.naming.client.WildFlyInitialContextFactory
java.naming.provider.url = remote://localhost:8323
java.naming.security.principal = ***
java.naming.security.credentials = ***
Connection Factory JNDI name = jms/RemoteConnectionFactory
Queue JNDI name = jms/test

此外,由于 principal/credentials 不是 ApplicationRealm 的一部分,我开始收到 403 HTTP 响应代码(在调用消息传递端点时)。为了让它也能正常工作,我必须使用 add-user.sh 脚本(在 Wildfly /bin 文件夹中找到)添加用户和相关凭证。