ActiveMQ with JBoss 7.2.0.Alpha1 / EAP 6.1.0.Alpha1

Update 26.8.2013:

Described steps also work with Wildfly Alpha 4. Tested the described configuration with urn:jboss:domain:resource-adapters:1.1 + mdb part in the standalone.xml and the latest rar.

—-

Working with an external ActiveMQ broker has become quite easy since my last attempts in the beginning of JBoss AS7. Here a short howto how to get it running in a few minutes – most of the steps are the same as already described under my former posting:

  1. Downloaded the latest release of the activemq.rar (.rar is – as .jar – a simple .zip file)
  2. Unzip the file and name the resulting folder activemq.rar
  3. Place this folder in the deployments directory of your JBoss AS
  4. Download ironjacamar.xml and place it into the META-INF folder of the activemq.rar folder
  5. Customize the existing ra.xml file if you don’t run activemq with default configuration on the same host
  6. Customize the ironjacamar.xml file as needed as queues and topics are configured here
  7. Edit the standalone.xml and add the following under urn:jboss:domain:ejb3:1.4. This change requires a restart (you could use the cli, I think…):
    <mdb>
      <resource-adapter-ref resource-adapter-name="activemq.rar" />
      <bean-instance-pool-ref pool-name="mdb-strict-max-pool" />
    </mdb>
  8. Create an empty file called activemq.rar.dodeploy

After these steps you should be able to deploy an application using MDB connected to ActiveMQ:

/*
 * 2013 (c) coffeebeans.at
 */
package at.coffeebeans.mq.listener;

import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.Message;
import javax.jms.MessageListener;

import org.jboss.logging.Logger;

/**
 * Class RemoteActiveMqListener demonstrating mdb with activemq.
 * @author manuel
 * 
 */
@MessageDriven(activationConfig = {
		@ActivationConfigProperty(propertyName = "destinationType",
				propertyValue = "javax.jms.Queue"),
		@ActivationConfigProperty(propertyName = "destination",
				propertyValue = "activemq/queue/TestQueue") })
public class RemoteActiveMqListener implements MessageListener {

	private static final Logger LOG = Logger
			.getLogger(RemoteActiveMqListener.class);

	/*
	 * (non-Javadoc)
	 * @see javax.jms.MessageListener#onMessage(javax.jms.Message)
	 */
	@Override
	public void onMessage(final Message msg) {
		LOG.debugf("received message: %s", msg);
	}

}

[/codesyntax]

 

instead of extracting the .rar file and customizing it, you can also configure the ressource  adapter in your standalone.xml file. To get the same configuration as before without any modification of the .rar file, simply add the following under urn:jboss:domain:resource-adapters:1.1 and deploy the original .rar file named activemq.rar:

<resource-adapters>
	<resource-adapter id="activemq.rar">
		<archive>
			activemq.rar
		</archive>
		<transaction-support>XATransaction</transaction-support>
		<config-property name="UseInboundSession">
			false
		</config-property>
		<config-property name="Password">
			defaultPassword
		</config-property>
		<config-property name="UserName">
			defaultUser
		</config-property>
		<config-property name="ServerUrl">
			tcp://localhost:61616
		</config-property>
		<connection-definitions>
			<connection-definition
				class-name="org.apache.activemq.ra.ActiveMQManagedConnectionFactory"
				jndi-name="java:jboss/exported/ConnectionFactory" enabled="true"
				use-java-context="true" pool-name="ConnectionFactory" />
		</connection-definitions>
		<admin-objects>
			<admin-object class-name="org.apache.activemq.command.ActiveMQQueue"
				jndi-name="java:jboss/activemq/queue/TestQueue" use-java-context="true"
				pool-name="TestQueue">
				<config-property name="PhysicalName">
					activemq/queue/TestQueue
				</config-property>
			</admin-object>
			<admin-object class-name="org.apache.activemq.command.ActiveMQTopic"
				jndi-name="java:jboss/activemq/topic/TestTopic" use-java-context="true"
				pool-name="TestTopic">
				<config-property name="PhysicalName">
					activemq/topic/TestTopic
				</config-property>
			</admin-object>
		</admin-objects>
	</resource-adapter>
</resource-adapters>

Leave a Comment