XS, Advanced XS Callback Patch For OCI, Part II
Well continuing along with my new chapter for XS Fun. Today I am just going to introduce the Oracle part of the equation and what one has do with OCI and Perl before
Oracle HA (High Availability) Events
A small part of Oracle's HA packages are notification that are sent out when an HA event takes place, This could be a server going down, one coming up one swapping out and a number of others.
Now to actually generate these events one need some specialized set up, first you need at least one Oracle RAC instance with at at least two Oracle Enterprise servers set up with and each mush have HA event notification enable. As well you OCI environment must be set up to allow OCI events and you have to have you system set up for threading.
If all this sounds complicated it is and expensive for all those RAC instances and enterprise servers quickly add up to big bucks and you really need to be quite a talented Oracle DB to set up all the requirements and ensure they are working. Well fortunately this is an XS book not an Oracle so lets say we just have the above all set up an running, as we are more interested in the XS code than the Oracle side of things.
Enough to say that when a trigger event happens Oracle will send out notices to it various parts to handle the event and keep the system up. Well one can tap into these notices and take action if require by registering a code reference to an OCI callback and when that event happens you code will fire.
We accomplish this utilizing 'OCIEventCallback' from OCI. Now if you look at the great big OCI book you will see that there is only about 6 paragraphs and 5 lines of example code so like I said earlier there never is much on OCI.
So the purpose of the patch is to allow Perl to send a function code ref into 'c' then use OCI to register this code in the Oracle environment so when a Perl HA event takes this code ref is fired and then someting happens in Perl. Easy no!
Well something like this is already in DBD::Oracle and it is called TAF or Transparent Application Failover which is the part of the Oracle HA system. Really this is just a quick way to set up automatic re-connection and the TAF callback can allow you to notify your users that the connection is down but is being reconnected.
Now onto XS side of things
Leave a comment