Initialization - MQ_INIT_EXIT
MQ_INIT_EXIT provides connection level initialization, indicated by setting ExitReason in MQAXP to MQXR_CONNECTION.
During the initialization, note the following:- The MQ_INIT_EXIT function calls MQXEP to register the IBM MQ API verbs and the ENTRY and EXIT points in which it is interested.
- Exits do not need to intercept all the IBM MQ API verbs. Exit functions are invoked only if an interest has been registered.
- Storage that is to be used by the exit can be acquired while initializing it.
- If a call to this function fails, the MQCONN or MQCONNX call that invoked it also fails with a CompCode and Reason that depend on the value of the ExitResponse field in MQAXP.
- An MQ_INIT_EXIT exit must not issue IBM MQ API calls, because the correct environment has not been set up at this time.
- If an MQ_INIT_EXIT fails with MQXCC_FAILED, the queue manager returns from the MQCONN or MQCONNX call that called it with MQCC_FAILED and MQRC_API_EXIT_ERROR.
- If the queue manager encounters an error while initializing the API exit function execution environment before invoking the first MQ_INIT_EXIT, the queue manager returns from the MQCONN or MQCONNX call that invoked MQ_INIT_EXIT with MQCC_FAILED and MQRC_API_EXIT_INIT_ERROR.
The interface to MQ_INIT_EXIT is:
MQ_INIT_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
- Pointer to completion code, valid values for which are:
- MQCC_OK
- Successful completion.
- MQCC_WARNING
- Partial completion.
- MQCC_FAILED
- Call failed
- Reason (MQLONG) - input/output
- Pointer to 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 or MQCC_WARNING, 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_INIT_EXIT (&ExitParms, &ExitContext, &CompCode, &Reason)Your exit must match the following C function prototype:
void MQENTRY MQ_INIT_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
- The MQ_INIT_EXIT function can issue the MQXEP call to register the addresses of the exit functions for the particular MQ calls to be intercepted. It is not necessary to intercept all MQ calls, or to intercept both MQXR_BEFORE and MQXR_AFTER calls. For example, an exit suite could choose to intercept only the MQXR_BEFORE call of MQPUT.
- Storage that is to be used by exit functions in the exit suite can be acquired by the MQ_INIT_EXIT function. Alternatively, exit functions can acquire storage when they are invoked, as and when needed. However, all storage should be freed before the exit suite is terminated; the MQ_TERM_EXIT function can free the storage, or an exit function invoked earlier.
- If MQ_INIT_EXIT returns MQXCC_FAILED in the ExitResponse field of MQAXP, or fails in some other way, the MQCONN or MQCONNX call that caused MQ_INIT_EXIT to be invoked also fails, with the CompCode and Reason parameters set to appropriate values.
- An MQ_INIT_EXIT function cannot issue MQ calls other than MQXEP.
Parent topic: Exit functions