Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g (10.1.3.1.0) Part Number B28221-02 |
|
|
View PDF |
If your MDB application uses OEMS JMS Database with an Oracle RAC database, you must configure your application to handle a database failover scenario, as follows:
Configure message-driven beans to retry if message dequeing fails (see "Using Deployment XML")
Configure the MDB client to retry if connection acquisition fails (see "Using Java")
Note:
The Oracle RAC-enabled attribute of a data source is discussed in Data Sources chapter in the Oracle Containers for J2EE Services Guide.To support Oracle RAC failover, you must configure orion-ejb-jar.xml
file element message-driven-deployment
attributes dequeue-retry-count
and dequeue-retry-interval
, as Example 18-4 shows.
The dequeue-retry-count
attribute tells the container how many times to retry the database connection in case a failure happens; the default is 0 seconds.
The dequeue-retry-interval
attribute tells the container how long to wait between retry attempts to accommodate for the time it takes for Oracle RAC database failover to complete; the default value is 60 seconds.
Example 18-4 orion-ejb-jar.xml For Oracle RAC Failover with an MDB
<message-driven-deployment name="MessageBeanTpc" connection-factory-location="java:comp/resource/cartojms1/TopicConnectionFactories/aqTcf" destination-location="java:comp/resource/cartojms1/Topics/topic1" subscription-name="MDBSUB" dequeue-retry-count=3 dequeue-retry-interval=90/> ...
To support Oracle RAC failover, you must configure a standalone OEMS JMS Database client running against an Oracle RAC database to retry if connection acquisition fails.
Oracle recommends that you use com.evermind.sql.DbUtil
method oracleFatalError
to determine if the connection object is invalid (see Example 18-5). If so, then reestablish the database connection, if necessary.
Example 18-5 Client Retrying After Connection Acquisition Failure
import com.evermind.sql.DbUtil; ... getMessage(QueueSesssion session) { try { QueueReceiver rcvr = session.createReceiver(rcvrQueue); Message msgRec = rcvr.receive(); } catch(Exception e ) { if (exc instanceof JMSException) { JMSException jmsexc = (JMSException) exc; sql_ex = (SQLException)(jmsexc.getLinkedException()); db_conn = oracle.jms.AQjmsSession)session.getDBConnection(); if ((DbUtil.oracleFatalError(sql_ex, db_conn)) { // failover logic } } } }