Integrating Apache ActiveMQ with Glassfish

Connectivity > Containers > Integrating Apache ActiveMQ with Glassfish


See this article for a description of how to connect Glassfish 3 to an ActiveMQ 5 broker, and consume messages using a Message Driven Bean:

Glassfish 4.1

  1. Add resource adapter
    1. Download the resource-adapter file suitable to your broker version:
    2. Deploy the  resource adapter with the name “activemq-rar”
      bin/asadmin deploy --type rar --name activemq-rar /tmp/activemq-rar-5.11.1.rar
    3. Configure resource adapter (Failover Setup)
      bin/asadmin create-resource-adapter-config --property ServerUrl='failover:(tcp://broker-c1.foobar.local:61616,tcp://broker-c2.foobar.local:61616,tcp://broker-c3.foobar.local:61616)?initialReconnectDelay=2000&jms.useCompression=true':UserName='admin':Password='admin' activemq-rar
  2. Create connector connection pool
    bin/asadmin create-connector-connection-pool \
      --raname activemq-rar \
      --connectiondefinition javax.jms.ConnectionFactory \
      --ping true --isconnectvalidatereq true \
  3. Create a connector resource (JNDI-Mapping for connection pool)
    bin/asadmin create-connector-resource \
      --poolname jms/myConnectionPool \
  4. Configure JNDI mapping for a queue
    bin/asadmin create-admin-object \
    	--raname activemq-rar \
      --restype javax.jms.Queue \
      --property PhysicalName=MY.MAGIC.OUT \
  5. Deploy your message driven beans and use the configured jndi names

Apache ActiveMQ, ActiveMQ, ActiveMQ Artemis, Apache, the Apache feather logo, and the Apache ActiveMQ project logo are trademarks of The Apache Software Foundation. Copyright © 2019, The Apache Software Foundation. Licensed under Apache License 2.0.