Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g (10.1.3.5.0) Part Number E13981-01 |
|
|
View PDF |
By default, OC4J uses one receiver thread to poll for messages from the message location.
Having more than one receiver thread allows messages to be received in parallel which can improve performance.
If your message location is a Topic, the number of receiver threads is fixed to one.
If your message location is a Queue, you can configure the number of receiver threads using OC4J-proprietary annotations (see "Using Annotations") or using the orion-ejb-jar.xml
file (see "Using Deployment XML").
Note that the minimum number of bean instances in the MDB pool should be at least the same as the number of receiver threads to avoid blocking receiver threads from acquiring a bean instance from the pool to process messages.
For more information, see:
How you configure this option depends on how you access your message-service provider you are using:
Accessing a Message Service Provider Using a J2CA Resource Adapter
Accessing a Message Service Provider Without Using a J2CA Resource Adapter
Accessing a Message Service Provider Using a J2CA Resource Adapter
If you access your message-service provider using a J2CA resource adapter, set activation configuration property ReceiverThreads
, as Example 10-3 shows.
For more information on ReceiverThreads
, see Table B-2.
Example 10-3 Configuring Parallel Message Processing for a J2CA Adapter 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="ReceiverThreads", propertyValue="3"), ... } ) @MessageDrivenDeployment( resourceAdapter = "OracleASjms", ... ) public class JCAQueueMDB implements MessageListener { public void onMessage(Message msg) { ... } }
Accessing a Message Service Provider Without Using a J2CA Resource Adapter
If you access your message-service provider directly (without using aJ2CA resource adapter), set OC4J-proprietary annotation @MessageDrivenDeployment
attribute listenerThreads, as Example 10-4 shows.
For more information on this @MessageDrivenDeployment
attribute, see Table A-3. For more information on the @MessageDrivenDeployment
annotation, see "Configuring OC4J-Proprietary Deployment Options on an EJB 3.0 MDB".
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:Example 10-4 Configuring Parallel Message Processing for a Non-J2CA Adapter Message Service Provider
import javax.ejb.MessageDriven; import oracle.j2ee.ejb.MessageDrivenDeployment; import javax.jms.Message; import javax.jms.MessageListener; @MessageDriven( ... ) @MessageDrivenDeployment( listenerThreads=3 ) public class QueueMDB implements MessageListener { public void onMessage(Message msg) { ... } }
For an EJB 3.0 message-driven bean, you configure parallel message processing in the orion-ejb-jar.xml
file as you would for an EJB 2.1 message-driven bean (see "Using Deployment XML").