Configure Message-Driven Beans
32.1. Configuring Message-Driven Beans The delivery of messages to an MDB using HornetQ is configured on the JCA Adapter via a configuration file ra.xml which can be found under the jms-ra.rar directory. By default this is configured to consume messages using an InVM connector from the instance of HornetQ running within the application server. The configuration properties are listed later in this chapter. All MDBs however need to have the destination type and the destination configured. The following example shows how this can be done using annotations: @MessageDriven(name = "MDBExample", activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/testQueue") }) @ResourceAdapter("hornetq-ra.rar") public class MDBExample implements MessageListener { public void onMessage(Message message)... } In this example you can see that the MDB will consume messages from a queue that is mapped into JNDI with the binding queue/testQueue. This queue must be preconfigured in the usual way using the HornetQ configuration files. The ResourceAdapter annotation is used to specify which adaptor should be used. To use this you will need to import org.jboss.ejb3.annotation.ResourceAdapter for JBoss AS 5.X and later version which can be found in the jboss-ejb3-ext-api.jar which can be found in the JBoss repository. For JBoss AS 4.X, the annotation to use is org.jboss.annotation.ejb.ResourceAdaptor. Alternatively you can add use a deployment descriptor and add something like the following to jboss.xml ExampleMDB hornetq-ra.rar You can also rename the hornetq-ra.rar directory to jms-ra.rar and neither the annotation or the extra descriptor information will be needed. If you do this you will need to edit the jms-ds.xml datasource file and change rar-name element. Note HornetQ is the default JMS provider for JBoss AS 6. Starting with this AS version, HornetQ resource adapter is named jms-ra.rar and you no longer need to annotate the MDB for the resource adapter name.