The Transaction Complete SA function is the user/system callback that is invoked after the transactions has been processed. 

After the transaction is completed the server will send “server-event” to notify subsystems that the Transaction Complete SA callbacks should be invoked. During this process the server checks if a subsystem has any callbacks to be invoked and sends a “server-event” message to the subsystem if it has registered Transaction Complete SA callback(s)Once the SIL-SA subsystem receives the “server-event” for Transaction Complete SA callbacks it will invoke the callbacks. 

The following function template definition is used for Transaction Complete SA callback functions:


/* Typedef of the Transaction Complete SA callback */
typedef void
    (*agt_cb_sa_trans_complete_t) (const xmlChar *transaction_id_val);


Callback Template

    

  • Type: User Callback
  • Max Callbacks: No limit (except available heap memory)
  • File: agt_cb.h
  • Template:   agt_cb_sa_trans_complete _t
    • Inputs:
      • transaction_id  == transaction ID of the transaction control block in progress
    • Outputs: none
    • Returns: none 
    • Register: agt_cb_sa_trans_complete_register
  • Unregister: agt_cb_sa_trans_complete_unregister


Register Callback


The Transaction Complete SA callback function is hooked into the server with the agt_cb_sa_trans_complete_register function, described below. 


extern status_t
    agt_cb_sa_trans_complete_register (agt_cb_sa_trans_start_t cbfn);


The register function is used to declare a specific callback function for Transaction Complete SA callbacks. The registration is done during the Initialization Phase 1 before the startup configuration is loaded into the running configuration database and before running configurations are loaded.

Initialization function with the registration of the Transaction Complete SA callback type may look as follows:



/******************************************************************** 
* FUNCTION interfaces_init
* 
* initialize the server instrumentation library.
* Initialization Phase 1
* 
*********************************************************************/ 
static status_t 
     interfaces_init (void) 
{ 
   ...

    /* Register a Transaction Complete callback. */
    res = agt_cb_sa_trans_complete_register(transaction_complete);
    if (res != NO_ERR) {
        return res;
    }

   ...
}



Callback Cleanup


The SIL-SA version of the Transaction Complete SA callback now have unregister functions (Since the versions 19.10-21 and 20.10-9). The callbacks can be cleaned up automatically whether when the subsystem goes away or when the server shuts down, but there will not be any cleanup during <unload> operation. As a result, the SIL-SA code must provide an unregister function to cleanup the callback during <unload> operation (versions 19.10-21 and 20.10-9).



The Transaction Start SA callback function is hooked into the server with the agt_cb_sa_trans_complete_unregister function, described below. The callback cleanup is getting done during module Cleanup Phase.


extern void
    agt_cb_sa_trans_complete_unregister (agt_cb_sa_trans_complete_t cbfn)


Callback Example



The following sections illustrates how to utilize the Transaction Complete SA callback in examples. 

In this example, the Transaction Complete SA callback function logs available parameters after the transaction is done.

The purpose of this function is to provide more validation options and more flexible and easier development. 

In addition, for example, the callback function can write a system or other log entries. 

The following example code illustrates how the Transaction Complete SA callback may look like.

 

/********************************************************************
* FUNCTION transaction_complete
*
* Complete Transaction callback
* The Complete Transaction function is the user/system
* callback that is invoked at the end of the transaction
*
*
* Max Callbacks: Unlimited
*
* INPUTS:
*   transaction_id_val == transaction id
*
* RETURNS:
*   status
********************************************************************/
static void
    transaction_complete (const xmlChar *transaction_id_val)
{

    if (!transaction_id_val) {
        log_error("\ntransaction_id value not set");
        return;
    }

    if (LOGDEBUG2) {
        log_debug2("\n\n********************************************\n");
        log_debug2("Enter silsa_transaction_complete callback for silsa-test "
                    "---- 1");
        log_debug2("\ntransaction_id -- %s", transaction_id_val);
        log_debug2("\n********************************************\n\n");
    }

    return;

} /* transaction_complete */


In the example above, the callback simply logs all the available parameters.
In this callback, there could be handling for customer specific pointers, it is a good place to clean up previously initialized pointers.