0

我很难让两个 WildFly 群应用程序(基于 2017.9.5 版本)通过独立的 ActiveMQ 5.14.3 代理相互通信。全部使用 YAML 配置完成,因为在我的情况下我没有 main 方法。

在阅读了数百个过时的示例和不准确的文档页面后,我为生产者和消费者应用程序设置了以下设置:

swarm:

  messaging-activemq:
    servers:
      default:
        jms-topics:
          domain-events: {}

  messaging:
    remote:
      name: remote-mq
      host: localhost
      port: 61616
      jndi-name: java:/jms/remote-mq

  remote: true

现在似乎至少部分设置在应用程序启动时是正确的,但以下警告除外:

2017-09-16 14:20:04,385 WARN  [org.jboss.activemq.artemis.wildfly.integration.recovery] (MSC service thread 1-2) AMQ122018: Could not start recovery discovery on XARecoveryConfig [transportConfiguration=[TransportConfiguration(name=, factory=org-apache-activemq-artemis-core-remoting-impl-netty-NettyConnectorFactory) ?port=61616&localAddress=::&host=localhost], discoveryConfiguration=null, username=null, password=****, JNDI_NAME=java:/jms/remote-mq], we will retry every recovery scan until the server is available

此外,当生产者尝试发送消息时,它只是超时并且我得到以下异常(只是最后一部分):

Caused by: javax.jms.JMSException: Failed to create session factory
    at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:727)
    at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createXAConnection(ActiveMQConnectionFactory.java:304)
    at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createXAConnection(ActiveMQConnectionFactory.java:300)
    at org.apache.activemq.artemis.ra.ActiveMQRAManagedConnection.setup(ActiveMQRAManagedConnection.java:785)
    ... 127 more
Caused by: ActiveMQConnectionTimedOutException[errorType=CONNECTION_TIMEDOUT message=AMQ119013: Timed out waiting to receive cluster topology. Group:null]
    at org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:797)
    at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:724)
    ... 130 more

我怀疑问题是 ActiveMQ 已打开安全性,但我发现没有地方可以将用户名和密码提供给 swarm 配置。

ActiveMQ 实例使用 Docker 和以下 compose 文件运行:

version: '2'

services:

  activemq:
    image: webcenter/activemq
    environment:
      - ACTIVEMQ_NAME=amqp-srv1
      - ACTIVEMQ_REMOVE_DEFAULT_ACCOUNT=true
      - ACTIVEMQ_ADMIN_LOGIN=admin
      - ACTIVEMQ_ADMIN_PASSWORD=your_password
      - ACTIVEMQ_WRITE_LOGIN=producer_login
      - ACTIVEMQ_WRITE_PASSWORD=producer_password
      - ACTIVEMQ_READ_LOGIN=consumer_login
      - ACTIVEMQ_READ_PASSWORD=consumer_password
      - ACTIVEMQ_JMX_LOGIN=jmx_login
      - ACTIVEMQ_JMX_PASSWORD=jmx_password
      - ACTIVEMQ_MIN_MEMORY=1024
      - ACTIVEMQ_MAX_MEMORY=4096
      - ACTIVEMQ_ENABLED_SCHEDULER=true

    ports:
      - "1883:1883"
      - "5672:5672"
      - "8161:8161"
      - "61616:61616"
      - "61613:61613"
      - "61614:61614"

知道出了什么问题吗?

4

1 回答 1

1

我也曾试图让它发挥作用。以下 YML 解决了我的问题:

swarm:
  network:
    socket-binding-groups:
      standard-sockets:
        outbound-socket-bindings:
          myapp-socket-binding:
            remote-host: localhost
            remote-port: 61616
  messaging-activemq:
    servers:
      default:
        remote-connectors:
          myapp-connector:
            socket-binding: myapp-socket-binding
        pooled-connection-factories:
          myAppRemote:
            user: username
            password: password
            connectors:
              - myapp-connector
            entries:
              - 'java:/jms/remote-mq'
于 2017-09-26T20:21:46.803 回答