How to use a Resource Adapter in your MDB?

In JBoss AS 7 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 xmlns="" 


This is a sample jboss-ejb3.xml file which can be deployed along with your EJB (or WEB) Project:

2. Annotate it in your MDB

Another option is by using the @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) {

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

Do you need some complete tutorials for configuring an external JMS provider on JBoss AS 7? Have a look here!

Follow us on Twitter