野飞18 JMS执行导致“在远程连接上突然关闭”

huangapple go评论87阅读模式
英文:

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

问题

我在本地运行了两个 Wildfly 18 实例:n1n2。我想让实例 n2 消费实例 n1 生产的消息,以朝着高可用(HA)场景迈出一步。
阅读了 RH EAP 文档 后,我已经完成了以下步骤:

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$6@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&amp;activemqServerName=default&amp;httpUpgradeEnabled=true&amp;port=<port_number>&amp;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&amp;activemqServerName=default&amp;httpUpgradeEnabled=true&amp;port=8323&amp;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&amp;activemqServerName=default&amp;httpUpgradeEnabled=true&amp;port=<port_number>&amp;host=localhost], discoveryGroupConfiguration=null]] is connected

但是,当我尝试使用以下 JNDI 配置从 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]]

请您指点我出现了什么问题,并解释为什么会出现这种情况?非常感谢。

英文:

I have two Wildfly 18 instances running locally: n1 and n2. I would like instance n2 to consume instance n1's produced messages in order to take steps towards a HA scenario.
After reading the RH EAP docs,
I have done the following:

1- Defined a Exposed JMS Queue on n2. Also, I added security settings and Remote Factory in the ActiveMQ Submodule:

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

2- I configured JGroups via TCPPING with an initial list of nodes to join the cluster, in order to achieve cluster discovery:

[...]
&lt;protocol type=&quot;org.jgroups.protocols.TCPPING&quot;&gt;
   &lt;property name=&quot;initial_hosts&quot;&gt;127.0.0.1[8600]&lt;/property&gt;
     &lt;property name=&quot;port_range&quot;&gt;0&lt;/property&gt;
 &lt;/protocol&gt;
[...]

3- Then I brought up the two instances, and there I get the following messages in the app logs:

(Thread-12 (ActiveMQ-server-org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl$6@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&amp;activemqServerName=default&amp;httpUpgradeEnabled=true&amp;port=&lt;port_number&gt;&amp;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&amp;activemqServerName=default&amp;httpUpgradeEnabled=true&amp;port=8323&amp;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&amp;activemqServerName=default&amp;httpUpgradeEnabled=true&amp;port=&lt;port_number&gt;&amp;host=localhost], discoveryGroupConfiguration=null]] is connected

But when I try to send messages from n1 to n2 using the following JNDI conf,

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

... I get this error after a certain timeout (~30s):

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)

I have tried to connect to the same queue using a simple JMS client (https://plugins.jetbrains.com/plugin/10949-jms-messenger), and I was actually able to connect, as I at least got the following error:

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

Could you please hint me on what is wrong and explain why that is? Thanks a lot

答案1

得分: 0

我通过对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"/>
   </server>
</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

另外,由于主体/凭据不属于ApplicationRealm的一部分,我开始收到403的HTTP响应代码(在调用消息端点时)。为了使其也正常工作,我不得不使用add-user.sh脚本(位于Wildfly的/bin文件夹中)添加用户和相关凭据。

英文:

I solved this issue by working on the Wildfly and JNDI configuration. Though the error message was very generic, at least in my case, the following Wildfly config:

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

Worked with the following JNDI config:

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

Also, as the principal/credentials were not part of the ApplicationRealm, I started getting a 403 HTTP response code (upon calling the messaging endpoint). In order to get that working too, I had to add the user and related credential using the add-user.sh script (found in the Wildfly /bin folder).

huangapple
  • 本文由 发表于 2020年9月10日 20:33:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/63829775.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定