Skip Headers

Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g Release 3 (10.1.3) B14428-01 |
| Home | Solution Area | Contents | Index

Previous | Next |

# Configuring an EJB 3.0 MDB to Use a Non-J2CA Message Service Provider

You can configure an EJB 3.0 MDB to use a non-J2CA message service provider using annotations (see "Using Annotations") or deployment XML (see "Using Deployment XML").

For more information, see:

- "Oracle Application Server JMS (OracleAS JMS) Provider: File-Based"

- "Oracle JMS (OJMS) Provider: Advanced Queueing (AQ)-Based"

## Using Annotations

You associate an EJB 3.0 MDB with a message service provider using the `@MessageDriven` annotation `activationConfig` attribute.

Example 10-3 shows how to configure a message-driven bean to use a non-J2CA JMS message service provider. It assumes that connection factory jms/MyQCF and queue jms/MyQueue are defined in the jms.xml file. For more information on configuring a non-J2CA message service provider, see "Configuring an OracleAS JMS Message Service Provider" or "Configuring an OJMS Message Service Provider".

Example 10-1 @MessageDriven Annotation for a Non-J2CA Message Service Provider

    import javax.ejb.ActivationConfigProperty;
    import javax.ejb.MessageDriven;
    import javax.jms.Message;
    import javax.jms.TextMessage;
    import javax.jms.MessageListener;

    @MessageDriven(
        messageListenerInterface=MessageListener.class,
        activationConfig = {
            @ActivationConfigProperty(
                propertyName="connectionFactoryJndiName", propertyValue="jms/MyQCF"),
            @ActivationConfigProperty(
                propertyName="destinationName", propertyValue="jms/MyQueue"),
            @ActivationConfigProperty(
                propertyName="destinationType", propertyValue="javax.jms.Queue"),
            @ActivationConfigProperty(
                propertyName="messageSelector", propertyValue="RECIPIENT = 'simple_test'")
        })

    public class QueueMDB implements MessageListener
    {
        public void onMessage(Message msg)
        {
            ...
        }
    }

The `@MessageDriven` annotation `activationConfig` attribute contains a list of `@ActivationConfigProperty` annotations whose `propertyName` and `propertyValue` attributes you use to specify activation configuration properties. Table 10-2 lists the mandatory and commonly used activation configuration properties you must set.

Table 10-2 Mandatory @ActivationConfigProperty Attributes

Property Name | Value
--- | ---
`connectionFactoryJndiName` | The JNDI name of the message service provider connection factory. You define this name when you configure your message service provider.
`destinationName` | The JNDI name of the message service provider destination name. You define this name when you configure your message service provider
`destinationType` | Specify the fully qualified class name of the destination type for your message service provider. For a JMS MDB, either `javax.jms.Queue` or `javax.jms.Topic`.
`messageSelector` | Specify the boolean expression of message properties that match the type of message your MDB should receive.

For a complete list of all activation configuration properties, download and unzip one of the `how-to-gjra-with-xxx.zip` files from `http://www.oracle.com/technology/tech/java/oc4j/1013/how_to/index.html`, where `xxx` is the name of the relevant resource provider. The `orion-ejb-jar.xml` demo file contains comments describing all activation configuration properties. For more information, see "JMS Resource Adapter" in the Oracle Containers for J2EE Services Guide.

The actual names you use depend on your message service provider installation. For more information, see:

- "OracleAS JMS Destination and Connection Factory Names"

- "OJMS Destination and Connection Factory Names"

## Using Deployment XML

You can associate an EJB 3.0 MDB with a non-J2CA message service provider by configuring the `ejb-jar.xml` file `message-driven` element with an `activation-config` element and `orion-ejb-jar.xml` file `message-driven-deployment` element with an `activation-config` element as you would for an EJB 2.1 MDB. Configuration in the `orion-ejb-jar.xml` file will overide annotations and `ejb-jar.xml` file configuration.

For more information, see "Using Deployment XML".