Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g (10.1.3.1.0) Part Number B28221-02 |
|
|
View PDF |
You can configure an EJB 3.0 MDB to access a message service provider using a J2CA resource adapter, such as the Oracle JMS Connector.
You can do this 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 "Restrictions When Accessing a Message Service Provider Without a J2CA Resource Adapter".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:
"Oracle JMS Connector: J2EE Connector Architecture (J2CA)-Based Provider"
"How do You Participate in a Global or Two-Phase Commit (2PC) Transaction?"
To configure an EJB 3.0 MDB to access a JMS message service provider using a J2CA resource adapter:
Specify the name of the resource adapter.
You may use either the OC4J-proprietary @MessageDrivenDeployment
annotation resourceAdapter attribute (as Example 10-1 shows) or the equivalent orion-ejb-jar.xml
file <message-driven-deployment>
element resource-adapter
attribute (see "Using Deployment XML").
Specify the required activation configuration properties.
You may specify activation configuration properties using any combination of @MessageDrivenDeployment
and @MessageDriven
annotation (as Example 10-1 shows) and deployment XML (see "Using Deployment XML").
For more information, see:
Example 10-1 shows how to configure a message-driven bean to use the Oracle JMS resource adapter named OracleASjms
. It assumes that you defined connection factory OracleASjms/MyQCF
in oc4j-ra.xml
file and destination name OracleASjms/MyQueue
in oc4j-connectors.xml
file 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 J2CA message service provider, see "Configuring a J2CA Resource Adapter for use With Your Message Service Provider".
Example 10-1 @MessageDriven and @MessageDrivenDeployment Annotation for a J2CA Message Service Provider
import javax.ejb.MessageDriven; import oracle.j2ee.ejb.MessageDrivenDeployment; import javax.ejb.ActivationConfigProperty; import javax.jms.Message; import javax.jms.MessageListener; @MessageDriven( activationConfig = { @ActivationConfigProperty( propertyName="ConnectionFactoryJndiName", propertyValue="OracleASjms/MyQCF"), @ActivationConfigProperty( propertyName="DestinationName", propertyValue="OracleASjms/MyQueue"), @ActivationConfigProperty( propertyName="DestinationType", propertyValue="javax.jms.Queue"), @ActivationConfigProperty( propertyName="messageSelector", propertyValue="RECIPIENT = 'simple_jca_test'") }) // associate MDB with the resource adapter @MessageDrivenDeployment(resourceAdapter = "OracleASjms") public class JCAQueueMDB implements MessageListener { public void onMessage(Message msg) { ... } }
The actual names you use depend on your message service provider installation. For more information, see "J2CA Message Service Provider Connection Factory Names".
To configure an EJB 3.0 MDB to access a JMS message service provider using 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.