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 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:
To configure an EJB 3.0 MDB to access a JMS message service provider using a J2CA resource adapter:
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:
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.