<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/book.oci8.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'oci8.fan.php',
    1 => 'OCI8 Fast Application Notification (FAN) Support',
    2 => 'OCI8 Fast Application Notification (FAN) Support',
  ),
  'up' => 
  array (
    0 => 'book.oci8.php',
    1 => 'OCI8',
  ),
  'prev' => 
  array (
    0 => 'oci8.connection.php',
    1 => 'OCI8 Connection Handling and Connection Pooling',
  ),
  'next' => 
  array (
    0 => 'oci8.taf.php',
    1 => 'OCI8 Transparent Application Failover (TAF) Support',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/oci8/fan.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="oci8.fan" class="chapter">
 <h1 class="title">OCI8 Fast Application Notification (FAN) Support</h1>

  <p class="para">
   FAN support gives fast connection failover, an Oracle Database high availability
   feature.  This allows PHP OCI8 scripts to be notified when a
   database machine or database instance becomes unavailable.  Without
   FAN, OCI8 can hang until a TCP timeout occurs and an error is
   returned, which might be several minutes.  Enabling FAN in OCI8 can
   allow applications to detect errors and re-connect to an available
   database instance without the web user being aware of an outage.
  </p>
  <p class="para">
   FAN support is available when the Oracle client libraries that PHP
   links with and the Oracle Database are either version 10gR2 or later.
  </p>
  <p class="para">
   FAN benefits users of Oracle&#039;s clustering technology (RAC) because
   connections to surviving database instances can be immediately
   made.  Users of Oracle&#039;s Data Guard with a broker will see the FAN
   events generated when the standby database goes online.  Standalone
   databases will send FAN events when the database restarts.
  </p>
  <p class="para">
   For active connections, when a machine or database instance becomes
   unavailable, a connection failure error will be returned by the
   OCI8 extension function currently being called.  On a subsequent
   PHP script re-connect, a connection to a surviving database
   instance will be established.  The OCI8 extension also
   transparently cleans up any idle connections affected by a database
   machine or instance failure so PHP connect calls will establish a
   fresh connection without the script being aware of any service
   disruption.
  </p>
  <p class="para">
   When <a href="oci8.configuration.php#ini.oci8.events" class="link">oci8.events</a>
   is <code class="literal">On</code>, it is suggested to
   set <a href="oci8.configuration.php#ini.oci8.ping-interval" class="link">oci8.ping_interval</a>
   to -1 to disable pinging, since enabling FAN events provide
   pro-active connection management of idle connections made invalid
   by a service disruption.
  </p>
  <p class="para">
   To enable FAN support in PHP OCI8, build PHP OCI8 with Oracle 10gR2 or later
   libraries and then follow these steps:
  </p>
  <p class="para">
   <ul class="itemizedlist">
    <li class="listitem">
     <span class="simpara">
      As a privileged database administrator, use a program like
      SQL*Plus to enable the database service to post FAN events, for
      example:
     </span>
     <p class="para">
      <div class="informalexample">
       <div class="example-contents screen">
<div class="cdata"><pre>
    SQL&gt; execute dbms_service.modify_service(
                   SERVICE_NAME        =&gt; &#039;sales&#039;,
                   AQ_HA_NOTIFICATIONS =&gt; TRUE);
</pre></div>
       </div>
      </div>
     </p>
    </li>
    <li class="listitem">
     <span class="simpara">
      Edit php.ini and add
     </span>
     <p class="para">
      <div class="informalexample">
       <div class="example-contents screen">
<div class="cdata"><pre>
    oci8.events = On
</pre></div>
       </div>
      </div>
     </p>
    </li>
    <li class="listitem">
     <span class="simpara">
      If the application does not already handle OCI8 error
      conditions, modify it to detect failures and take appropriate
      action.  This may include re-connecting and re-executing
      statements.
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      Run the application, connecting to Oracle Database 10gR2 or later.
     </span>
    </li>
   </ul>
  </p>
</div>
<?php manual_footer($setup); ?>