Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g (10.1.3.1.0) Part Number B28221-02 |
|
|
View PDF |
You can configure the maximum number of times OC4J will attempt the immediate redelivery of a message to the message-driven bean's message listener method (for example, the onMessage
method for a JMS message listener) if that method returns failure (fails to invoke an acknowledgment operation, throws an exception, or both).
After this number of redeliveries, the message is deemed undeliverable and is handled according to the policies of your message service provider. For example, OEMS JMS will put the message on its exception queue (jms/Oc4jJmsExceptionQueue
).
You can configure the maximum delivery count using OC4J-proprietary annotations (see "Using Annotations") or using the orion-ejb-jar.xml
file (see "Using Deployment XML").
For more information, see "Message Service Configuration Options: Annotations or XML? Attributes or Activation Configuration Properties?".
How you configure this option depends on the type of 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 MaxDeliveryCnt
, as Example 10-5 shows.
For more information on MaxDeliveryCnt
, see Table B-2.
Example 10-5 Configuring Maximum Delivery Count 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="MaxDeliveryCnt", 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 a J2CA resource adapter), set OC4J-proprietary annotation @MessageDrivenDeployment
attribute maxDeliveryCount, as Example 10-6 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-6 Configuring Maximum Delivery Count 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( maxDeliveryCount=3 ) public class QueueMDB implements MessageListener { public void onMessage(Message msg) { ... } }
For an EJB 3.0 message-driven bean, you configure the maximum delivery count in the orion-ejb-jar.xml
file as you would for an EJB 2.1 message-driven bean (see "Using Deployment XML").