Potentially, the otl_subscriber class may throw the following OTL defined exception.
class otl_subscriber {
public:
Function |
Description |
||||||||||
otl_subscriber(otl_connect* adb); |
General constructor. It accepts a pointer to an otl_connect object. When the constructor is called, the otl_connect object doesn't necessarily have to be connected to the database. It needs to be connected by the time of the first subscribe() call. | ||||||||||
virtual ~otl_subscriber(); | Destructor. Closes all active subscriptions automatically. | ||||||||||
void subscribe(...);
|
Subscribes to Change Notifications / activate Change Notification Interface | ||||||||||
void unsubscribe(); |
Unsubscribes / deactivates Change Notification Interface | ||||||||||
void associate_table |
Associates a table / view of interest with the current subscription. In other words, add a table / view name to the list of tables / views which we want to get change notifications on. There may be more than one table / view in the list | ||||||||||
void associate_query(const char *query_stmt); | Associates
a query of
interest with the current subscription. In other words, adds a query to
the list of queries which we want to get change
notifications on. There may be more than one query in the list. This
function is a more generic version of the associate_table()
function.
When the query gets executed, all the underlying objects of the query
get identified. The query format should be as follows: SELECT :arg<int> FROM...the rest of the query... :arg<int> is needed in order to postpone the execution of the query, when the query gets opened in an otl_stream inside the function: otl_stream s(1,stmt,*db); ... s<<0; ... |
||||||||||
bool is_online(void); | Checks
if
the current subscription is
active (online). This function is convenient to call from OnDeRegistration()
in order to identify
whether the subscription was expired by the client or by the server
timeout. |
protected:// Pure virtual functions // callbacks to be implemented in a derived class:
Function |
Description |
virtual void
OnException (OTL_CONST_EXCEPTION otl_exception& e) = 0; |
"On otl_exception" callback.
When OTL
throws otl_exception, this function is called. OTL_CONST_EXCEPTION is
defined as "const" under #define OTL_ANSI_CPP. Otherwise, it
is empty (""). |
virtual
void
OnDeRegistration (void) = 0; |
"On deregistration" callback. This function gets called when the current subscription expires. Inside this function, repeated calls to subscribe(), associate_table(), associate_query() are allowed. |
virtual void OnStartup(void) = 0; | DB-wide event. "On Oracle Instance startup" callback. This function gets called on the Oracle Instance startup |
virtual
void
OnInstanceShutdown (void) = 0; |
DB-wide event. "On Oracle Instance shutdown" callback. This function gets called when the Oracle Instance which the client program is connected to shuts down. |
virtual
void
OnAnyInstanceShutdown (void) = 0; |
DB-wide event. "On Any Oracle Instance shutdown" callback. This function gets called when Any Oracle Instance in the RAC which the client program is connected to shuts down. |
virtual
void
OnTableInvalidate (text *table_name) = 0; |
Table-wide event. "On table invalidate" callback. This function gets called when the table gets invalidated. |
virtual void OnTableAlter(text *table_name, bool all_rows=false) = 0; | Table-wide event. "On table alter" callback. This function gets called when the table gets ALTERed. If all_rows is true then the whole table has been affected |
virtual
void OnTableDrop (text *table_name, bool all_rows=false) = 0; |
Table-wide event. "On table drop" callback. This function gets called when the table gets DROPped. If all_rows is true then the whole table has been affected |
virtual
void OnTableChange (text *table_name, bool all_rows=false) = 0; |
Table-wide event. "On table change" callback. This function gets called when the table gets changed: INSERT, UPDATE, DELETE. This callback only informs of the fact that the table got changed, but it doesn't specify which row(s) got changed. In order to get the info on individual rows, see "Row events". If all_rows is true then the whole table has been affected. |
virtual void
OnRowInsert (text *table_name, text *row_id ) = 0; |
Row event. "On row insert" callback. This function gets called when a row is inserted into the table. If a query was associated with the current subscription that involves more than one table, this callback will be invoked for each table of the query. "row_id" is the ROWID of the inserted row. |
virtual void
OnRowUpdate (text *table_name, text *row_id ) = 0; |
Row event. "On row update" callback. This function gets called when a table row is updated. If a query was associated with the current subscription that involves more than one table, this callback will be invoked for each table of the query. "row_id" is the ROWID of the updated row. |
virtual
void OnRowDelete (text *table_name, text *row_id ) = 0; |
Row
event. "On row delete" callback. This function gets called when
a table row is updated. If a query was associated with the current
subscription that involves more than one table, this callback will be
invoked for each table of the query. "row_id" is the ROWID of the
updated row. |
}; // end of otl_subscriberOracle user id that is used to connect to the database and get Change Notifications needs to have the CHANGE NOTIFICATION privilege given by the DBA, for example:
select * from USER_CHANGE_NOTIFICATION_REGSWhen a subscription gets registered, the OCI layer opens a specified TCP/IP port, and spawns a new listener thread. Firewalls need to take the TCP/IP port into account.
Copyright © 1996-2024, Sergei Kuchin, email: skuchin@gmail.com, skuchin@gmail.com .
Permission to use, copy, modify and redistribute this document for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.