Termination - MQ_TERM_EXIT

MQ_TERM_EXIT provides connection level termination, registered with a function identifier of MQXF_TERM and ExitReason MQXR_CONNECTION. If registered, MQ_TERM_EXIT is called once for every disconnect request.

As part of the termination, storage no longer required by the exit can be released, and any clean up required can be performed.

If an MQ_TERM_EXIT fails with MQXCC_FAILED, the queue manager returns from the MQDISC that called it with MQCC_FAILED and MQRC_API_EXIT_ERROR.

If the queue manager encounters an error while terminating the API exit function execution environment after invoking the last MQ_TERM_EXIT, the queue manager returns from the MQDISC call that invoked MQ_TERM_EXIT with MQCC_FAILED and MQRC_API_EXIT_TERM_ERROR

The interface to this function is:
MQ_TERM_EXIT (&ExitParms, &ExitContext, &CompCode, &Reason)
where the parameters are:

    ExitParms (MQAXP) - input/output
    Exit parameter structure.

    ExitContext (MQAXC) - input/output
    Exit context structure.

    CompCode (MQLONG) - input/output
    Completion code, valid values for which are:

      MQCC_OK
      Successful completion.

      MQCC_FAILED
      Call failed

    Reason (MQLONG) - input/output
    Reason code qualifying the completion code. If the completion code is MQCC_OK, the only valid value is:

      MQRC_NONE
      (0, x'000') No reason to report.

    If the completion code is MQCC_FAILED, the exit function can set the reason code field to any valid MQRC_* value.

    The CompCode and Reason returned to the application depend on the value of the ExitResponse field in MQAXP.


C language invocation

The queue manager logically defines the following variables:
        MQAXP           ExitParms;      /* Exit parameter structure */
        MQAXC           ExitContext;    /* Exit context structure */
        MQLONG          CompCode;       /* Completion code */
        MQLONG          Reason;         /* Reason code */
The queue manager then logically calls the exit as follows:
MQ_TERM_EXIT (&ExitParms, &ExitContext, &CompCode, &Reason)
Your exit must match the following C function prototype:
void MQENTRY MQ_TERM_EXIT (
PMQAXP          pExitParms,     /* Address of exit parameter structure */
PMQAXC          pExitContext,   /* Address of exit context structure */
PMQLONG         pCompCode,      /* Address of completion code */
PMQLONG         pReason);       /* Address of reason code qualifying
                                   completion code */


Usage notes

  1. The MQ_TERM_EXIT function is optional. It is not necessary for an exit suite to register a termination exit if there is no termination processing to be done.

    If functions belonging to the exit suite acquire resources during the connection, an MQ_TERM_EXIT function is a convenient point at which to free those resources, for example, freeing storage obtained dynamically.

  2. If an MQ_TERM_EXIT function is registered when the MQDISC call is issued, the exit function is invoked after all of the MQDISC exit functions have been invoked.
  3. If MQ_TERM_EXIT returns MQXCC_FAILED in the ExitResponse field of MQAXP, or fails in some other way, the MQDISC call that caused MQ_TERM_EXIT to be invoked also fails, with the CompCode and Reason parameters set to appropriate values.

Parent topic: Exit functions