Thorntail JMS到远程ActiveMQ服务器?

时间:2019-05-16 18:30:52

标签: java jms activemq activemq-artemis thorntail

我正在创建一个简单的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]

我不确定导致该问题的配置丢失了什么。谁能告诉我我在做什么错?

1 个答案:

答案 0 :(得分: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)。