How to use a Resource Adapter in your MDB?

In WildFly you can bind your MDBs to a specific Resource Adapter in three ways. Here’s how to do it!

1. At deployment descriptor level (jboss-ejb3.xml)

<jboss xmlns="" 


The above, is a sample jboss-ejb3.xml file which can be deployed along with your EJB (or WEB) project, which in turns maps the following MDB:

@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 {


2. Annotate it in your MDB

Another option is by using the @org.jboss.ejb3.annotation.ResourceAdapter annotation within your MDB:

activationConfig = { 
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName="destination", propertyValue="java:jboss/activemq/queue/LocalRPCRequest")
name = "ActiveMQMDB")
public class ActiveMQMDB implements MessageListener {

    public ActiveMQMDB() {}

    public void onMessage(Message message) {
    try {    
    if(message instanceof TextMessage) {
    System.out.println("Got Message "+((TextMessage)message).getText());
        catch (JMSException e) {

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


3. Configure it at MDB Pool level

If you want to configure the Resource adapter for all the MDBs in your pool, then you can just configure it in the EJB3 subsystem:

<subsystem xmlns="urn:jboss:domain:ejb3:1.4">

. . . . .

        <resource-adapter-ref resource-adapter-name="activemq-rar-5.7.0.rar"/>
        <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>


Remember that you need to declare your resource adapter in a file name ironjacamar.xml which can be deployed alogn with your .rar file, or configure the resource adapter into the resource-adapters subsystem:

<subsystem xmlns="urn:jboss:domain:resource-adapters:1.0">