| Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g (10.1.3.5.0) Part Number E13981-01 |
|
|
View PDF |
You can configure an EJB 2.1 MDB to access a message service provider using a J2CA resource adapter such as the Oracle JMS Connector.
You can do this using 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 2.1 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. You use the orion-ejb-jar.xml file configuration to override settings in ejb-jar.xml and to add the OC4J-specific setting for resource adapter. For example, the connection factory and destination name that you define in ejb-jar.xml may be logical names that may not exist in your local JNDI environment. The deployer can override these settings in the orion-ejb-jar.xml file and map them to the actual names. For more information on mapping logical names, see "Configuring an Environment Reference to a JMS Destination or Connection Resource Manager Connection Factory (JMS 1.0)".
To configure an EJB 2.1 MDB to use a J2CA message service provider:
Specify the name of the resource adapter.
You do this using the orion-ejb-jar.xml file <message-driven-deployment> element resource-adapter attribute as Example 18-1 shows.
Specify the required activation configuration properties.
You may specify activation configuration properties using any combination of <config-property> elements in the orion-ejb-jar.xml file <message-driven-deployment> element (as Example 18-1 shows) and <activation-config-property> elements in the ejb-jar.xml file <message-driven> element (as Example 18-2 shows). The orion-ejb-jar.xml file configuration overrides that in the ejb-jar.xml file.
For more information, see:
Example 18-1 shows how to configure the orion-ejb-jar.xml file to configure this message-driven bean to use the Oracle JMS resource adapter named OracleASjms. You must set the resource-adapter attribute. Optionally, you can override or configure additional activation configuration properties using one or more config-property elements.
Example 18-1 orion-ejb-jar.xml for a J2CA Message Service Provider
<message-driven-deployment
name="JCA_QueueMDB"
resource-adapter="OracleASjms">
...
<config-property>
<config-property-name>DestinationName</config-property-name>
<config-property-value>OracleASJMSRASubcontext/MyQ</config-property-value>
</config-property>
...
</message-driven-deployment>
Example 18-2 shows how to configure ejb-jar.xml 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 the oc4j-ra.xml file and destination name OracleASjms/MyQueue in the oc4j-connectors.xml 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, see "Configuring Message Services".
Example 18-2 ejb-jar.xml for a J2CA Message Service Provider
<message-driven>
<ejb-name>JCA_QueueMDB</ejb-name>
<ejb-class>test.JCA_MDB</ejb-class>
<messaging-type>javax.jms.MessageListener</messaging-type>
<transaction-type>Container</transaction-type>
<activation-config>
<activation-config-property>
<activation-config-property-name>
DestinationType
</activation-config-property-name>
<activation-config-property-value>
javax.jms.Queue
</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>
DestinationName
</activation-config-property-name>
<activation-config-property-value>
OracleASjms/MyQueue
</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>
ConnectionFactoryJndiName
</activation-config-property-name>
<activation-config-property-value>
OracleASjms/MyQCF
</activation-config-property-value>
</activation-config-property>
</activation-config>
</message-driven>
You may also set the optional attributes that Table A-3 lists.
The actual names you use depend on your message service provider installation. For more information, see "J2CA Message Service Provider Connection Factory Names".