Skip Headers
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g Release 3 (10.1.3)
B14428-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

Configuring an MDB for Oracle RAC Failover

If your MDB application uses OJMS with an Oracle RAC database, you must configure your application to handle a database failover scenario, as follows:


Note:

The RAC-enabled attribute of a data source is discussed in Data Sources chapter in the Oracle Containers for J2EE Services Guide.

Using Deployment XML

To support 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 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/>
...

Using Java

To support RAC failover, you must configure a standalone OJMS client running against an 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 re-establish 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
            }
        }
    }
}