# mco_trans_rt_register_callback
RT

> Register a real-time transaction callback function for deadline monitoring.

### Prototype

        typedef MCO_RET (*mco_trans_rt_callback_t)(mco_trans_h t);

        MCO_RET mco_trans_rt_register_callback(
            /*IN*/ mco_db_h db,
            /*IN*/ mco_trans_rt_callback_t callback
        );

### Arguments

`db`
Database handle (represents a connection to the database).
`callback`
Pointer to a user-defined callback function of type `mco_trans_rt_callback_t`. May be `NULL` to unregister a previously set callback.

### Description

> This function registers a callback that is invoked by the eXtremeDB/rt kernel at predefined cancellation points during real-time transaction execution. The callback allows the application to check whether the transaction has exceeded its deadline and decide whether to continue or abort.

> The callback is registered per database connection. If your application uses multiple connections for real-time transactions, you must register the callback separately for each one.

> The callback function receives the current transaction handle and must return:

> - `MCO_S_OK` — the transaction is still within its deadline and may continue,
> - `MCO_E_INTERRUPTED` — the transaction has exceeded its deadline; the kernel will mark the transaction as interrupted, and the application should roll it back.

> Once a transaction is marked as interrupted (due to `MCO_E_INTERRUPTED`), all subsequent database operations within that transaction will also return `MCO_E_INTERRUPTED` until the transaction is rolled back.

### Return Codes

`MCO_S_OK`
Callback registered successfully.
`MCO_E_INTERRUPTED`
Transaction was interrupted by timer, callback, or another transaction.

### Files

Header file:
mco.h
Source file:
mcoabst.c
Library:
libmcolib.a