Skip Headers
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g (10.1.3.5.0)

Part Number E13981-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

Configuring an EJB 3.0 MDB to Access a Message Service Provider Directly

You can configure an EJB 3.0 MDB to access a message service provider directly (without a J2CA resource adapter).

You can do this by using annotations (see "Using Annotations") or deployment XML (see "Using Deployment XML").

Note:

Oracle recommends that you access a message service provider using a J2CA resource adapter such as the Oracle JMS Connector. For more information, see:

OC4J supports both XA factories for two-phase commit (2PC) transactions and non-XA factories for transactions that do not require 2PC.

For more information, see:

Using Annotations

To configure an EJB 3.0 MDB to access a JMS message service provider using a J2CA resource adapter:

  1. Specify the required activation configuration properties.

    You may specify activation configuration properties using any combination of @MessageDrivenDeployment annotation, @MessageDriven annotation, and deployment XML.

    For more information, see:

Example 10-11 shows how to configure a message-driven bean to access a JMS message service provider directly (without a J2CA resource adapter). It assumes that you defined connection factory jms/MyQCF and queue jms/MyQueue when you configured your message service provider. You can define either XA-enabled factories for two-phase commit (2PC) support or non-XA factories if 2PC support is not required. For more information on configuring a message service provider, see "Configuring Message Services".

Example 10-2 @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 actual names you use depend on your message service provider installation. For more information, see the following:

Using Deployment XML

To configure an EJB 3.0 MDB to access a JMS message service provider directly (without a J2CA resource adapter) by using deployment XML, you must use both ejb-jar.xml and orion-ejb.jar.xml files, as you would for an EJB 2.1 MDB (see "Using Deployment XML").

You can override annotation configuration (see "Using Annotations"), if present, with this deployment XML configuration.