繁体   English   中英

Thorntail JMS 到远程 ActiveMQ 服务器?

[英]Thorntail JMS to Remote ActiveMQ Server?

我正在创建一个简单的 Thorntail 服务,它将向远程 ActiveMQ 队列写入文本消息,并让 MDB 使用该消息。 为了测试这一点,我在本地 Docker 容器中运行了 ActiveMQ。 docker-compose.yml文件的相关部分如下所示:

activemq:
  image: webcenter/activemq
  ports:
      - 1883:1883
      - 5672:5672
      - 8161:8161
      - 61613:61613
      - 61614:61614
      - 61616:61616
  environment:
      - ACTIVEMQ_CONFIG_NAME=holocron-mq
      - ACTIVEMQ_CONFIG_DEFAULTACCOUNT=false
      - ACTIVEMQ_ADMIN_LOGIN=mqadmin
      - ACTIVEMQ_ADMIN_PASSWORD=password
      - ACTIVEMQ_CONFIG_QUEUES_queue1=myqueue1
      - ACTIVEMQ_CONFIG_SCHEDULERENABLED=true
      - ACTIVEMQ_USERS_edgeproducer=password
      - ACTIVEMQ_USERS_edgeconsumer=password

我的 Thorntail project-defaults.yml文件已配置为使用以下配置连接到此“远程”服务器:

swarm:
  network:
    socket-binding-groups:
      standard-sockets:
        outbound-socket-bindings:
          remote-activemq-socket-binding:
            remote-host: 127.0.0.1
            remote-port: 61616
  messaging-activemq:
    servers:
      default:
        remote-connectors:
          remote-activemq-connector:
            socket-binding: remote-activemq-socket-binding
        pooled-connection-factories:
          remote-connection-factory:
            user: edgeproducer
            password: password
            connectors:
              - remote-activemq-connector
            entries:
              - 'java:/jms/remote-mq'
              - 'java:/DefaultJMSConnectionFactory'
        jms-queues:
          session-tracking-queue:
            entries:
              entry: 'java:/jms/queue/testQueue'

我的 JAX-RS 服务有以下 2 个 JMS 属性(最终)允许我写入队列:

@Inject
@JMSConnectionFactory("java:/jms/remote-mq")
private JMSContext jmsContext = null;

@Resource(mappedName = "java:/jms/queue/testQueue")
private Queue processingQueue = null;

最后,我的 MDB 具有以下注释以允许它从队列中读取:

@MessageDriven(activationConfig = {
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName = "destination", propertyValue = "java:/jms/queue/testQueue"),
        @ActivationConfigProperty(propertyName = "maxSession", propertyValue = "10") })
@ResourceAdapter("remote-connection-factory")

但是,当我启动 Thorntail uberjar 时,出现以下错误:

AMQ214031: Failed to decode buffer, disconnect immediately.: java.lang.IllegalStateException: java.lang.IllegalArgumentException: AMQ119032: Invalid type: 1
AMQ212037: Connection failure has been detected: java.lang.IllegalArgumentException: AMQ119032: Invalid type: 1 [code=GENERIC_EXCEPTION]

我不确定导致此问题的配置中到底遗漏了什么。 任何人都可以阐明我做错了什么吗?

您正在尝试将 ActiveMQ Artemis “核心”JMS 客户端(即 Thorntail 中的默认 JMS 客户端实现)与 ActiveMQ 5.x 代理一起使用。 ActiveMQ Artemis 是下一代 ActiveMQ 消息代理,Artemis 核心 JMS 客户端无法与 5.x 代理通信。 我建议您在 Docker 容器中使用 ActiveMQ Artemis。 它与 5.x 代理支持的 OpenWire JMS 客户端实现向后兼容,它还支持所有其他协议(例如 AMQP、STOMP、MQTT)。

暂无
暂无

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

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