How to use a Resource Adapter in your MDB?

This article is a walk though the configuration of a Resource Adapter in WildFly application server. At first, we will learn how to configure it in the resource-adapter subsystem and how to use the adapter in your MDB..

You can configure a Resource Adapters through the resource-adapters subsystem. Behind the hoods, the IronJacamar project provides support for the Java Connector Architecture.

jboss configure resource adapter

Configuring the Resource Adapter involves the following steps:

  1. At first, you need to deploy the Resource Adapter (or as an alternative, install is as a module)
  2. Then, you need to add the Resource Adapter Configuration
  3. Finally, you can annotate your Message Driver Beans to use the Resource Adapter
  4. Optionally, you can also configure the Resource Adapter as the Default one for your MDBs.

Let’s see all steps in greater detail.

Installing the Resource Adapter

The simplest way to install the Resource Adapter consists in copying it under the deployments folder of the application server. Example:

cp wmq.jmsra.rar $JBOSS_HOME/standalone/deployments

Configuring the Resource Adapter

The next step will be adding the RA to the configuration. A resource adapter definition can provide support for XA Transactions. If you want to use XA Transaction after adding it you need to specify the Security Domain for it:

/subsystem=resource-adapters/resource-adapter=wmq.jmsra.rar:add(archive=wmq.jmsra.rar, transaction-support=XATransaction)


On the other hand, if you don’t need support for XA Transactions you can simply add it as follows:

/subsystem=resource-adapters/resource-adapter=wmq.jmsra.rar:add(archive=wmq.jmsra.rar, transaction-support=NoTransaction)

Finally, include the connection-definitions and config-properties of the Resource Adapter. Example:

<subsystem xmlns="urn:jboss:domain:resource-adapters:5.0">
        <resource-adapter id="wmq.jmsra.rar">
                <connection-definition class-name=""
                                       jndi-name="java:jboss/jms/ivt/IVTCF" enabled="true" use-java-context="true"
                    <config-property name="channel">SYSTEM.DEF.SVRCONN
                    <config-property name="transportType">
                    <config-property name="queueManager">
                    <config-property name="port">
                <connection-definition class-name=""
                                       jndi-name="java:jboss/jms/ivt/JMS2CF" enabled="true" use-java-context="true"
                    <config-property name="channel">
                    <config-property name="hostName">
                    <config-property name="transportType">
                    <config-property name="queueManager">
                    <config-property name="port">
            <admin-object class-name=""
                          jndi-name="java:jboss/jms/ivt/IVTQueue" pool-name="IVTQueue">
                <config-property name="baseQueueName">

Configure MDBs to use the Resource Adapter

Next, you can refer to the Resource Adapter id in your Message Driven Beans:

@MessageDriven(name="IbmMqMdb", activationConfig = {
        @ActivationConfigProperty(propertyName = "connectionFactoryLookup", propertyValue = "java:jboss/jms/ivt/IVTCF"),
        @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "java:jboss/jms/ivt/IVTQueue"),
        @ActivationConfigProperty(propertyName = "destinationType",propertyValue = "javax.jms.Queue")
@ResourceAdapter(value = "wmq.jmsra.rar")
public class IBMMDB implements MessageListener {
    public void onMessage(Message message) {

Please notice that the above @ResourceAdapter annotation requires a JBoss specific dependency to be used:


Decoupling the Resource Adapter from the MDB

If you want to avoid tight coupling between the RAR file and the MDB, you can specify the Resource Adapter name at deployment descriptor level (jboss-ejb3.xml). Example:

<jboss xmlns="" 


With the above jboss-ejb3.xml configuration in place, you can refer to the generic “SOCKET_MDB” in your @MessageDriven annotation:

@MessageDriven(name = "SOCKET_MDB", activationConfig = {
        @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue.demoQueue"),
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")
},mappedName = "java:/jms/demoQueue")

public class HelloWorldQueueMDB implements MessageListener {


Configuring the Resource Adapter as the default one

By default, the application server uses the ArtemisMQ Resource adapter as the default one for your MDB Pool:

    <resource-adapter-ref resource-adapter-name="${ejb.resource-adapter-name:activemq-ra.rar}"/>
    <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>

To use a different one for your EJB Container, simply change the resource-adapter-name property accordingly. For example:

    <resource-adapter-ref resource-adapter-name="${ejb.resource-adapter-name:wmq.jmsra.rar}"/>
    <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
Found the article helpful? if so please follow us on Socials