简体   繁体   中英

Thorntail JMS to Remote ActiveMQ Server?

I am creating a simple Thorntail service that will write a text message to a remote ActiveMQ queue, and have that message consumed by an MDB. To test this, I've got ActiveMQ running in a local Docker container. The relevant portion of my docker-compose.yml file looks like this:

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

My Thorntail project-defaults.yml file has been configured to connect to this "remote" server with this configuration:

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'

My JAX-RS service has the following 2 JMS properties to (eventually) allow me to write to the queue:

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

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

Finally, my MDB has the following annotations to allow it to read from the queue:

@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")

However, when I start my Thorntail uberjar, I get the following errors:

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]

I'm not sure exactly what I've missed in my configuration that is causing this issue. Can anyone shed any light on what I'm doing wrong?

You're attempting to use an ActiveMQ Artemis "core" JMS client (ie the default JMS client implementation in Thorntail) with an ActiveMQ 5.x broker. ActiveMQ Artemis is the next-generation of ActiveMQ message broker and the Artemis core JMS client can't talk to the 5.x broker. I recommend you use ActiveMQ Artemis in your Docker container. It is backwards compatible with the OpenWire JMS client implementation which the 5.x broker supports and it also supports all the other protocols (eg AMQP, STOMP, MQTT).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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