# JBoss EJB 3.0 MDB JCA Inflow

This chapter provides two examples on JCA 1.5 resources that allow JMS delivery of messages to EJB 3.0 Message Driven Beans. The first example uses SwiftMQ as the JCA XA resource. The second example illustrates the usage of non-standard (i.e. not javax.jms.MessageListener) messaging types.

## SwiftMQ JCA XA Resource

SwiftMQ provide a JCA 1.5 resource that allows JMS message delivery to an MDB. The EJB 3.0 distribution provides a tutorial on building and deploying this example. The @org.jboss.annotation.ejb.ResourceAdapter annotation is used to designate the resource adapter you will be using. It takes an attribute that is the base name of the RAR deployment file name.

Here is the source listing for the MDB:

    @MessageDriven(name="test/mdb", activationConfig =
    {
    @ActivationConfigProperty(propertyName="messagingType", propertyValue="javax.jms.MessageListener"),
    @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
    @ActivationConfigProperty(propertyName="Destination", propertyValue="testqueue"),
    @ActivationConfigProperty(propertyName="ConnectionFactoryName", propertyValue="ConnectionFactory"),
    @ActivationConfigProperty(propertyName="Transacted", propertyValue="true"),
    @ActivationConfigProperty(propertyName="Xa", propertyValue="true"),
    @ActivationConfigProperty(propertyName="DeliveryOption", propertyValue="B"),
    @ActivationConfigProperty(propertyName="SubscriptionDurability", propertyValue="Durable"),
    @ActivationConfigProperty(propertyName="MaxPoolSize", propertyValue="20"),
    @ActivationConfigProperty(propertyName="MaxMessages", propertyValue="1"),
    })
    @ResourceAdapter("switfmq.rar")
    public class AnnotatedTestMDBBean
       implements MessageListener
    {
       public void onMessage(Message message)
       {
          System.out.println(message);
       }
    }

## Non-Standard Messaging Types

JBoss offers the capability use non-standard messaging types for Message Driven Beans. Standard MDBs implement the javax.jms.MessageListener interface. MDBs can alternatively implement a custom messaging interface. The EJB 3.0 distribution test suite provides a complete example for the usage of this bean.

Here is the source listing for a non-standard messaging type:

    @MessageDriven(name = "TestMDB", activationConfig =
    {
    @ActivationConfigProperty(propertyName="messagingType", propertyValue="org.jboss.ejb3.test.jca.inflow.TestMessageListener"),
    @ActivationConfigProperty(propertyName="name", propertyValue="testInflow"),
    @ActivationConfigProperty(propertyName="anInt", propertyValue="5"),
    @ActivationConfigProperty(propertyName="anInteger", propertyValue="55"),
    @ActivationConfigProperty(propertyName="localhost", propertyValue="127.0.0.1"),
    @ActivationConfigProperty(propertyName="props", propertyValue="key1=value1,key2=value2,key3=value3")
    })
    @ResourceAdapter("jcainflow.rar")
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public class TestMDBMessageListener implements TestMessageListener
    {
       private static final Logger log = Logger.getLogger(TestMDBMessageListener.class);

       public void deliverMessage(TestMessage message)
       {
          message.acknowledge();
          log.info(message.toString());
       }
    }