【问题标题】:Thorntail JMS to Remote ActiveMQ Server?Thorntail JMS 到远程 ActiveMQ 服务器?
【发布时间】:2020-08-30 10:24:20
【问题描述】:

我正在创建一个简单的 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? activemq.2283324.n4.nabble.com/… 似乎也有类似的问题,升级帮助了...
  • 我使用的 Docker 镜像是针对 ActiveMQ 5.14.3 的。知道什么版本可以解决这个问题吗?
  • 这家伙有同样的问题 [org.apache.activemq.artemis.core.client] AMQ214031: 无法解码缓冲区,立即断开连接。: java.lang.IllegalStateException: java.lang.IllegalArgumentException: AMQ119032:无效类型:1——所以我猜你的问题是相关的。但从线程中我无法找出解决方案。

标签: java jms activemq-artemis thorntail


【解决方案1】:

您正在尝试将 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)。

【讨论】:

  • 轰隆隆!做到了!感谢您的帮助!
  • @Shadowman 你做了什么?使用独立(docker)Artemis 服务器?我正在使用您的配置,但我总是收到以下错误:“WFLYCTL0180:缺少/不可用依赖项的服务”=> [“jboss.naming.context.java.module.booking.booking.DefaultJMSConnectionFactory is missing [jboss.naming. context.java.jboss.DefaultJMSConnectionFactory]", "jboss.deployment.unit.\"booking.war\".component.ExampleMdb.CREATE 缺失 [jboss.ra.remote-connection-factory]"]
猜你喜欢
  • 2013-10-03
  • 2023-03-26
  • 2010-12-20
  • 2012-11-12
  • 2016-07-17
  • 2019-06-08
  • 2022-12-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多