This section contains reference information, mainly of interest to the programmer writing API exits. It covers:
Here we describe the structure of the external control blocks, MQAXP and MQAXC.
The MQAXP structure is used as an input/output parameter to the API exit. MQAXP has the following C declaration:
typedef struct tagMQAXP { MQCHAR4 StrucId; /* Structure identifier */ MQLONG Version; /* Structure version number */ MQLONG ExitId; /* Exit Identifier */ MQLONG ExitReason; /* Exit invocation reason */ MQLONG ExitResponse; /* Response code from exit */ MQLONG ExitResponse2; /* Secondary response code from exit */ MQLONG Feedback; /* Feedback code from exit */ MQLONG APICallerType; /* MQSeries API caller type */ MQBYTE16 ExitUserArea; /* User area for use by exit */ MQCHAR32 ExitData; /* Exit data area */ MQCHAR48 ExitInfoName; /* Exit information name */ MQBYTE48 ExitPDArea; /* Problem determination area */ MQCHAR48 QMgrName; /* Name of local queue manager */ PMQACH ExitChainAreaPtr; /* Inter exit communication area */ MQHCONFIG Hconfig; /* Configuration handle */ MQLONG Function; /* Function Identifier */ };
The parameter list described below is passed when functions in an API exit are invoked:
MQAXP_STRUC_ID.
The exit handler sets this field on entry to each exit function.
The exit handler sets this field on entry to each exit function.
This field must be set by the exit function, to communicate to the queue manager the result of executing the exit function. The value must be one of the following:
This value can be set by all MQXR_* exit functions. ExitResponse2 is used to decide whether exit functions later in the chain should be invoked.
This value can be set by all MQXR_* exit functions. The queue manager sets CompCode to MQCC_FAILED, and Reason to:
The values set can be altered by an exit function later in the chain.
ExitResponse2 is ignored; the queue manager continues processing as though MQXR2_SUPPRESS_CHAIN had been returned.
This value can be set only by an MQXR_BEFORE exit function. It bypasses the API call. If it is returned by the MQ_DATA_CONV_ON_GET_EXIT, data conversion is bypassed. The queue manager sets CompCode to MQCC_FAILED, and Reason to MQRC_SUPPRESSED_BY_EXIT, but the values set can be altered by an exit function later in the chain. Other parameters for the call remain as the exit left them. ExitResponse2 is used to decide whether exit functions later in the chain should be invoked.
If this value is set by an MQXR_AFTER or MQXR_CONNECTION exit function, the queue manager continues processing as though MQXCC_FAILED had been returned.
This value can be set only by an MQXR_BEFORE exit function. It bypasses the API call. If it is returned by the MQ_DATA_CONV_ON_GET_EXIT, data conversion is bypassed. The exit function must set CompCode and Reason to the values to be returned to the application, but the values set can be altered by an exit function later in the chain. Other parameters for the call remain as the exit left them. ExitResponse2 is used to decide whether exit functions later in the chain should be invoked.
If this value is set by an MQXR_AFTER or MQXR_CONNECTION exit function, the queue manager continues processing as though MQXCC_FAILED had been returned.
This value can be set only by the MQXR_BEFORE and MQXR_AFTER exit functions. It bypasses all subsequent invocations of exit functions belonging to this set of exits for this logical connection. This bypassing continues until the logical disconnect request occurs, when MQ_TERM_EXIT function is invoked with an ExitReason of MQXR_CONNECTION.
The exit function must set CompCode and Reason to the values to be returned to the application, but the values set can be altered by an exit function later in the chain. Other parameters for the call remain as the exit left them.ExitResponse2 is ignored.
If this value is set by an MQXR_CONNECTION exit function, the queue manager continues processing as though MQXCC_FAILED had been returned.
For information on the interaction between ExitResponse and ExitResponse2, and its affect on exit processing, see How queue managers process exit functions.
MQXR2_DEFAULT_CONTINUATION
on entry to a WebSphere MQ API call exit function. It can then be set to one of the values:
If ExitResponse is MQXCC_SUPPRESS_FUNCTION or MQXCC_SKIP_FUNCTION, bypass exit functions later in the MQXR_BEFORE chain and the matching exit functions in the MQXR_AFTER chain. Invoke exit functions in the MQXR_AFTER chain that match exit functions earlier in the MQXR_BEFORE chain.
Otherwise, invoke the next exit in the chain.
Bypass exit functions later in the MQXR_BEFORE chain and the matching exit functions in the MQXR_AFTER chain for this API call invocation. Invoke exit functions in the MQXR_AFTER chain that match exit functions earlier in the MQXR_BEFORE chain.
For information on the interaction between ExitResponse and ExitResponse2, and its affect on exit processing, see How queue managers process exit functions.
MQFB_NONE (0)
before invocation of the first function of the first exit in a chain.
Exits can set this field to any value, including any valid MQFB_* or MQRC_* value. Exits can also set this field to a user-defined feedback value in the range MQFB_APPL_FIRST to MQFB_APPL_LAST.
This field is aligned to a multiple of 4 MQLONGs.
Exits can also anchor any storage that they allocate from this area.
For each hconn, each exit in a chain of exits has a different ExitUserArea. The ExitUserArea cannot be shared by exits in a chain, and the contents of the ExitUserArea for one exit are not available to another exit in a chain.
For C programs, the constant MQXUA_NONE_ARRAY is also defined with the same value as MQXUA_NONE, but as an array of characters instead of a string.
The length of this field is given by MQ_EXIT_USER_AREA_LENGTH.
The length of this field is given by MQ_EXIT_DATA_LENGTH.
For C programs, the constant MQXPDA_NONE_ARRAY is also defined with the same value as MQXPDA_NONE, but as an array of characters instead of a string.
The exit handler always writes this area to the WebSphere MQ trace at the end of an exit, even when the function is successful.
The length of this field is given by MQ_EXIT_PD_AREA_LENGTH.
If the name of a queue manager supplied on an MQCONN or MQCONNX calls is blank, this field is still set to the name of the local or default queue manager.
The exit handler sets this field on entry to each exit function.
The length of this field is given by MQ_Q_MGR_NAME_LENGTH.
Refer to The exit chain area and exit chain area header (MQACH) for more details about how to use the exit chain area.
The exit handler sets this field to the correct value, on entry to each exit function, depending on the WebSphere MQ API call that resulted in the exit being invoked.
The processing performed by the queue manager on return from an exit function depends on both ExitResponse and ExitResponse2. Table 10 below summarizes the possible combinations and their effects for an MQXR_BEFORE exit function, showing:
For an MQXR_AFTER exit function:
For an MQXR_CONNECTION exit function:
In all cases, where an exit or the queue manager sets CompCode and Reason,
the values set can be changed by an exit invoked later, or by the API call (if
the API call is invoked later).
Table 10. MQXR_BEFORE exit processing
Value of ExitResponse | CompCode and Reason set by | Value of ExitResponse2 (default continuation) Chain | Value of ExitResponse2 (default continuation) API |
MQXCC_OK | exit | Y | Y |
MQXCC_SUPPRESS_EXIT | exit | Y | Y |
MQXCC_SUPPRESS_FUNCTION | queue manager | N | N |
MQXCC_SKIP FUNCTION | exit | N | N |
MQXCC_FAILED | queue manager | N | N |
The MQAXC structure is used as an input parameter to an API exit. MQAXC has the following C declaration:
typedef struct tagMQAXC { MQCHAR4 StrucId; /* Structure identifier */ MQLONG Version; /* Structure version number */ MQLONG Environment; /* Environment */ MQCHAR12 UserId; /* UserId associated with appl */ MQBYTE40 SecurityId /* Extension to UserId running appl */ MQCHAR264 ConnectionName; /* Connection name */ MQLONG LongMCAUserIdLength; /* long MCA user identifier length */ MQLONG LongRemoteUserIdLength; /* long remote user identifier length */ MQPTR LongMCAUserIdPtr; /* long MCA user identifier address */ MQPTR LongRemoteUserIdPtr; /* long remote user identifier address */ MQCHAR28 ApplName; /* Application name */ MQLONG ApplType; /* Application type */ MQPID ProcessId; /* Process identifier */ MQTID ThreadId; /* Thread identifier */ };
The parameters to MQAXC are:
The exit handler sets this field on entry to each exit function.
The exit handler sets this field on entry to each exit function.
The exit handler sets this field on entry to each exit function.
The exit handler sets this field on entry to each exit function. The length of this field is given by MQ_USER_ID_LENGTH.
The length of this field is given by MQ_CONN_NAME_LENGTH.
When MCA connects to the queue manager this field is set to the length of the long MCA user identifier (or zero if there is no such identifier).
When MCA connects to the queue manager this field will be set to the length of the long remote user identifier. Otherwise this field will be set to zero
When MCA connects to the queue manager this field is set to the address of the long MCA user identifier (or to a null pointer if there is no such identifier).
When MCA connects to the queue manager this field is set to the address of the long remote user identifier (or to a null pointer if there is no such identifier).
The rules for generating the ApplName are the same as for generating the default name for an MQPUT.
The value of this field is found by querying the operating system for the program name. Its length is given by MQ_APPL_NAME_LENGTH.
The value is MQAT_DEFAULT for the platform on which the application is compiled, or it equates to one of the defined MQAT_* values.
The exit handler sets this field on entry to each exit function.
Where applicable, the exit handler sets this field on entry to each exit function.
Where applicable, the exit handler sets this field on entry to each exit function.
If required, an exit function can acquire storage for an exit chain area and set the ExitChainAreaPtr in MQAXP to point to this storage.
Exits (either the same or different exit functions) can acquire multiple exit chain areas and link them together. Exit chain areas must only be added or removed from this list while called from the exit handler. This ensures there are no serialization issues caused by different threads adding or removing areas from the list at the same time.
An exit chain area must start with an MQACH header structure, the C declaration for which is:
typedef struct tagMQACH { MQCHAR4 StrucId; /* Structure identifier */ MQLONG Version; /* Structure version number */ MQLONG StrucLength; /* Length of the MQACH structure */ MQLONG ChainAreaLength; /* Exit chain area length */ MQCHAR48 ExitInfoName /* Exit information name */ PMQACH NextChainAreaPtr; /* Pointer to next exit chain area */ };
The fields in the exit chain area header are:
For C programs, the constant MQACH_STRUC_ID_ARRAY is also defined; this has the same value as MQACH_STRUC_ID, but as an array of characters instead of a string.
The initial value of this field, defined by MQACH_DEFAULT, is MQACH_CURRENT_VERSION.
The initial value of this field, defined by MQACH_DEFAULT. is MQACH_CURRENT_LENGTH.
The initial value of this field, defined by MQACH_DEFAULT, is zero.
When an exit creates an MQACH structure, it must initialize this field with its own ExitInfoName, so that later this MQACH structure can be found by either another instance of this exit, or by a cooperating exit.
The initial value of this field, defined by MQACH_DEFAULT, is a zero length string ({""} ).
Exit functions must release the storage for any exit chain areas that they acquire, and manipulate the chain pointers to remove their exit chain areas from the list.
An exit chain area can be constructed as follows:
MQAXP.ExitChainAreaPtr ---* *-----------------------* *--> *-----*---*----*-----*----------------------------------------------* | ACH | 1 | 80 | --* | First exit's chain area | *-----*---*----*---|-*----------------------------------------------* *-----------------------* *--> *-----*---*----*-----*---------------------------* | ACH | 1 | 64 | --* | Second exit's chain area | *-----*---*----*---|-*---------------------------* *-----------------------* *--> ... etc.
The following new external constants are available for API exits:
MQXF_INIT 1 X'00000001' MQXF_TERM 2 X'00000002' MQXF_CONN 3 X'00000003' MQXF_CONNX 4 X'00000004' MQXF_DISC 5 X'00000005' MQXF_OPEN 6 X'00000006' MQXF_CLOSE 7 X'00000007' MQXF_PUT1 8 X'00000008' MQXF_PUT 9 X'00000009' MQXF_GET 10 X'0000000A' MQXF_DATA_CONV_ON_GET 11 X'0000000B' MQXF_INQ 12 X'0000000C' MQXF_SET 13 X'0000000D' MQXF_BEGIN 14 X'0000000E' MQXF_CMIT 15 X'0000000F' MQXF_BACK 16 X'00000010'
MQXR_BEFORE 1 X'00000001' MQXR_AFTER 2 X'00000002' MQXR_CONNECTION 3 X'00000003'
MQXE_OTHER 0 X'00000000' MQXE_MCA 1 X'00000001' MQXE_MCA_SVRCONN 2 X'00000002' MQXE_COMMAND_SERVER 3 X'00000003' MQXE_MQSC 4 X'00000004'
MQAXP_VERSION_1 1 MQAXC_VERSION_1 1 MQACH_VERSION_1 1 MQAXP_CURRENT_VERSION 1 MQAXC_CURRENT_VERSION 1 MQACH_CURRENT_VERSION 1 MQXACT_EXTERNAL 1 MQXACT_INTERNAL 2 MQXT_API_EXIT 2 MQACH_LENGTH_1 68 (32-bit platforms) 72 (64-bit platforms) 80 (128-bit platforms) MQACH_CURRENT_LENGTH 68 (32-bit platforms) 72 (64-bit platforms) 80 (128-bit platforms)
MQXPDA_NONE X'00...00' (48 nulls) MQXPDA_NONE_ARRAY '\0','\0',...,'\0','\0'
MQXCC_FAILED -8
Examine both the ExitResponse and ExitResponse2 fields of the MQAXP to determine the bad response code, and change the exit to return a valid response code.
Examine the value of the ExitReason field to determine and correct the bad exit reason value.
Examine the value of the Reserved field to determine and correct the Reserved value.
Here are the C language typedefs associated with the API exits:
typedef PMQLONG MQPOINTER PPMQLONG; typedef PMQBYTE MQPOINTER PPMQBYTE; typedef PMQHOBJ MQPOINTER PPMQHOBJ; typedef PMQOD MQPOINTER PPMQOD; typedef PMQMD MQPOINTER PPMQMD; typedef PMQPMO MQPOINTER PPMQPMO; typedef PMQGMO MQPOINTER PPMQGMO; typedef PMQCNO MQPOINTER PPMQCNO; typedef PMQBO MQPOINTER PPMQBO; typedef MQAXP MQPOINTER PMQAXP; typedef MQACH MQPOINTER PMQACH; typedef MQAXC MQPOINTER PMQAXC; typedef MQCHAR MQCHAR16[16]; typedef MQCHAR16 MQPOINTER PMQCHAR16; typedef MQLONG MQPID; typedef MQLONG MQTID;
Use the MQXEP call to:
You would usually code the MQXEP calls in the MQ_INIT_EXIT exit function, but you can specify them in any subsequent exit function.
If you use an MQXEP call to register an already registered exit function, the second MQXEP call completes successfully, replacing the registered exit function.
If you use an MQXEP call to register a NULL exit function, the MQXEP call will complete successfully and the exit function is de-registered.
If MQXEP calls are used to register, de-register, and re-register a given exit function during the life of a connection request, the previously registered exit function is reactivated. Any storage still allocated and associated with this exit function instance is available for use by the exit's functions. (This storage is usually released during the invocation of the termination exit function).
The interface to MQXEP is:
MQXEP (Hconfig, ExitReason, Function, EntryPoint, Reserved, &CompCode, &Reason)
where:
If the completion code is MQCC_OK:
If the completion code is MQCC_FAILED:
Either use one of the valid exit function invocation reasons (MQXR_* value), or use a valid function identifier and exit reason combination. (See Table 11.)
Table 11. Valid combinations of function identifiers and ExitReasons
Function | ExitReason |
---|---|
MQXF_INIT MQXF_TERM | MQXR_CONNECTION |
MQXF_CONN MQXF_CONNX MQXF_DISC MQXF_OPEN MQXF_CLOSE MQXF_PUT1 MQXF_PUT MQXF_GET MQXF_INQ MQXF_SET MQXF_BEGIN MQXF_COMMIT MQXF_BACK |
MQXR_BEFORE MQXR_AFTER |
MQXF_DATA_CONV_ON_GET | MQXR_BEFORE |
MQXEP (Hconfig, ExitReason, Function, EntryPoint, &CompCode, &Reason);
Declaration for parameter list:
MQHCONFIG Hconfig; /* Configuration handle */ MQLONG ExitReason; /* Exit reason */ MQLONG Function; /* Function identifier */ PMQFUNC EntryPoint; /* Function entry point */ MQLONG CompCode; /* Completion code */ MQLONG Reason; /* Reason code qualifying completion code */
void MQXEP ( MQHCONFIG Hconfig, /* Configuration handle */ MQLONG ExitReason, /* Exit reason */ MQLONG Function, /* Function identifier */ PMQFUNC EntryPoint, /* Function entry point */ PMQLONG pCompCode, /* Address of completion code */ PMQLONG pReason); /* Address of reason code qualifying completion code */
This section tells you how to invoke the exit functions available. The descriptions of the individual functions start at The API exit functions. This section begins with some general information to help you when using these function calls.
The following general rules apply when invoking API exit routines:
In general, all errors from exit functions are communicated back to the exit handler using the ExitResponse and ExitResponse2 fields in MQAXP. These errors in turn are converted into MQCC_* and MQRC_* values and communicated back to the application in the CompCode and Reason fields. However, any errors encountered in the exit handler logic are communicated back to the application as MQCC_* and MQRC_* values in the CompCode and Reason fields.
If an MQ_TERM_EXIT function returns an error:
In other words, the exit cannot be unloaded as it may still be in use. Also, other registered exits further down in the exit chain for which the before exit was successful, will be driven in the reverse order.
While processing an explicit MQCONN or MQCONNX call, exit handling logic sets up the exit execution environment before invoking the exit initialization function (MQ_INIT_EXIT). Exit execution environment setup involves loading the exit, acquiring storage for, and initializing exit parameter structures. The exit configuration handle is also allocated at this point.
If errors occur during this phase, the MQCONN or MQCONNX call fails with CompCode MQCC_FAILED and one of the following reason codes:
While processing an explicit MQDISC call, or an implicit disconnect request as a result of an application ending, exit handling logic may need to clean up the exit execution environment after invoking the exit termination function (MQ_TERM_EXIT), if registered. Cleaning up the exit execution environment involves releasing storage for exit parameter structures, possibly deleting any modules previously loaded into memory.
If errors occur during this phase, an explicit MQDISC call fails with CompCode MQCC_FAILED and the following reason code (errors will not be highlighted on implicit disconnect requests):
This section describes each of the exit functions and its parameters, as follows:
MQ_BACK_EXIT provides a backout exit function to perform before and after backout processing. Use function identifier MQXF_BACK with exit reasons MQXR_BEFORE and MQXR_AFTER to register before and after backout call exit functions.
The interface to this functions:
MQ_BACK_EXIT (&ExitParms, &ExitContext, &Hconn, &CompCode, &Reason)
where the parameters are:
If the completion code is MQCC_OK, the only valid value is:
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 queue manager logically defines the following variables:
MQAXP ExitParms; /* Exit parameter structure */ MQAXC ExitContext; /* Exit context structure */ MQHCONN Hconn; /* Connection handle */ MQLONG CompCode; /* Completion code */ MQLONG Reason; /* Reason code qualifying completion code */
The queue manager then logically calls the exit as follows:
MQ_BACK_EXIT (&ExitParms, &ExitContext, &Hconn, &CompCode, &Reason);
Your exit must match the following C function prototype:
void MQENTRY MQ_BACK_EXIT ( PMQAXP pExitParms, /* Address of exit parameter structure */ PMQAXC pExitContext, /* Address of exit context structure */ PMQHCONN pHconn, /* Address of connection handle */ PMQLONG pCompCode, /* Address of completion code */ PMQLONG pReason); /* Address of reason code qualifying completion code */
MQ_BEGIN_EXIT provides a begin exit function to perform before and after MQBEGIN call processing. Use function identifier MQXF_BEGIN with exit reasons MQXR_BEFORE and MQXR_AFTER to register before and after MQBEGIN call exit functions.
The interface to this function is:
MQ_BEGIN_EXIT (&ExitParms, &ExitContext, &Hconn, &pBeginOptions, &CompCode, &Reason)
where the parameters are:
If the completion code is MQCC_OK, the only valid value is:
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 queue manager logically defines the following variables:
MQAXP ExitParms; /* Exit parameter structure */ MQAXC ExitContext; /* Exit context structure */ MQHCONN Hconn; /* Connection handle */ PMQBO pBeginOptions; /* Ptr to begin options */ MQLONG CompCode; /* Completion code */ MQLONG Reason; /* Reason code qualifying completion code */
The queue manager then logically calls the exit as follows:
MQ_BEGIN_EXIT (&ExitParms, &ExitContext, &Hconn, &pBeginOptions, &CompCode, &Reason);
Your exit must match the following C function prototype:
void MQENTRY MQ_BEGIN_EXIT ( PMQAXP pExitParms, /* Address of exit parameter structure */ PMQAXC pExitContext, /* Address of exit context structure */ PMQHCONN pHconn, /* Address of connection handle */ PPMQBO ppBeginOptions, /* Address of ptr to begin options */ PMQLONG pCompCode, /* Address of completion code */ PMQLONG pReason); /* Address of reason code qualifying completion code */
MQ_CLOSE_EXIT provides a close exit function to perform before and after MQCLOSE call processing. Use function identifier MQXF_CLOSE with exit reasons MQXR_BEFORE and MQXR_AFTER to register before and after MQCLOSE call exit functions.
The interface to this function is:
MQ_CLOSE_EXIT (&ExitParms, &ExitContext, &Hconn, &pHobj, &Options, &CompCode, &Reason)
where the parameters are:
If the completion code is MQCC_OK, the only valid value is:
If the completion code is MQCC_FAILED, the exit function can set the reason code field to any valid MQRC_* value.
The queue manager logically defines the following variables:
MQAXP ExitParms; /* Exit parameter structure */ MQAXC ExitContext; /* Exit context structure */ MQHCONN Hconn; /* Connection handle */ PMQHOBJ pHobj; /* Ptr to object handle */ MQLONG Options; /* Close options */ MQLONG CompCode; /* Completion code */ MQLONG Reason; /* Reason code */
The queue manager then logically calls the exit as follows:
MQ_CLOSE_EXIT (&ExitParms, &ExitContext,&Hconn, &pHobj, &Options, &CompCode, &Reason);
Your exit must match the following C function prototype:
void MQENTRY MQ_CLOSE_EXIT ( PMQAXP pExitParms, /* Address of exit parameter structure */ PMQAXC pExitContext, /* Address of exit context structure */ PMQHCONN pHconn, /* Address of connection handle */ PPMQHOBJ ppHobj, /* Address of ptr to object handle */ PMQLONG pOptions, /* Address of close options */ PMQLONG pCompCode, /* Address of completion code */ PMQLONG pReason); /* Address of reason code qualifying completion code */
MQ_CMIT_EXIT provides a commit exit function to perform before and after commit processing. Use function identifier MQXF_CMIT with exit reasons MQXR_BEFORE and MQXR_AFTER to register before and after commit call exit functions.
If a commit operation fails, and the transaction is backed out, the MQCMIT call fails with MQCC_WARNING and MQRC_BACKED_OUT. These return and reason codes are passed into any after MQCMIT exit functions to give the exit functions an indication that the unit of work has been backed out.
The interface to this function is:
MQ_CMIT_EXIT (&ExitParms, &ExitContext, &Hconn, &CompCode, &Reason)
where the parameters are:
If the completion code is MQCC_OK, the only valid value is:
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 queue manager logically defines the following variables:
MQAXP ExitParms; /* Exit parameter structure */ MQAXC ExitContext; /* Exit context structure */ MQHCONN Hconn; /* Connection handle */ MQLONG CompCode; /* Completion code */ MQLONG Reason; /* Reason code qualifying completion code */
The queue manager then logically calls the exit as follows:
MQ_CMIT_EXIT (&ExitParms, &ExitContext,&Hconn, &CompCode, &Reason);
Your exit must match the following C function prototype:
void MQENTRY MQ_CMIT_EXIT ( PMQAXP pExitParms, /* Address of exit parameter structure */ PMQAXC pExitContext, /* Address of exit context structure */ PMQHCONN pHconn, /* Address of connection handle */ PMQLONG pCompCode, /* Address of completion code */ PMQLONG pReason); /* Address of reason code qualifying completion code */
MQ_CONNX_EXIT provides:
The same interface, as described below, is invoked for both MQCONN and MQCONNX call exit functions.
When the message channel agent (MCA) responds to an inbound client connection, the MCA can connect and make a number of WebSphere MQ API calls before the client state is fully known. These API calls result in the API exit functions being called with the MQAXC based on the MCA program itself (for example in the UserId and ConnectionName fields of the MQAXC).
When the MCA responds to subsequent inbound client API calls, the MQAXC structure is based on the inbound client, setting the UserId and ConnectionName fields appropriately.
The queue manager name set by the application on an MQCONN or MQCONNX call is passed to the underlying connect call. Any attempt by a before MQ_CONNX_EXIT to change the name of the queue manager has no effect.
Use function identifiers MQXF_CONN and MQXF_CONNX with exit reasons MQXR_BEFORE and MQXR_AFTER to register before and after MQCONN and MQCONNX call exit functions.
An MQ_CONNX_EXIT exit called for reason MQXR_BEFORE must not issue any WebSphere MQ API calls, as the correct environment has not been set up at this time.
The interface to MQCONN and MQCONNX is identical:
MQ_CONNX_EXIT (&ExitParms, &ExitContext, &pQMgrName, &pConnectOpts, &pHconn, &CompCode, &Reason);
where the parameters are:
See "MQCNO - Connect options" in the WebSphere MQ Application Programming Reference for details.
For exit function MQXF_CONN, pConnectOpts points to the default connect options structure (MQCNO_DEFAULT).
If the completion code is MQCC_OK, the only valid value is:
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 queue manager logically defines the following variables:
MQAXP ExitParms; /* Exit parameter structure */ MQAXC ExitContext; /* Exit context structure */ PMQCHAR pQMgrName; /* Ptr to Queue manager name */ PMQCNO pConnectOpts; /* Ptr to Connection options */ PMQHCONN pHconn; /* Ptr to Connection handle */ MQLONG CompCode; /* Completion code */ MQLONG Reason; /* Reason code */
The queue manager then logically calls the exit as follows:
MQ_CONNX_EXIT (&ExitParms, &ExitContext, &pQMgrName, &pConnectOps, &pHconn, &CompCode, &Reason);
Your exit must match the following C function prototype:
void MQENTRY MQ_CONNX_EXIT ( PMQAXP pExitParms, /* Address of exit parameter structure */ PMQAXC pExitContext, /* Address of exit context structure */ PPMQCHAR ppQMgrName, /* Address of ptr to queue manager name */ PPMQCNO ppConnectOpts, /* Address of ptr to connection options */ PPMQHCONN ppHconn, /* Address of ptr to connection handle */ PMQLONG pCompCode, /* Address of completion code */ PMQLONG pReason); /* Address of reason code qualifying completion code */
MQ_DISC_EXIT provides a disconnect exit function to perform before and after MQDISC exit processing. Use function identifier MQXF_DISC with exit reasons MQXR_BEFORE and MQXR_AFTER to register before and after MQDISC call exit functions.
The interface to this function is
MQ_DISC_EXIT (&ExitParms, &ExitContext, &pHconn, &CompCode, &Reason);
where the parameters are:
For the before MQDISC call, the value of this field is one of:
For the after MQDISC call, the value of this field is zero or a value set by a previous exit function invocation.
If the completion code is MQCC_OK, the only valid value is:
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 queue manager logically defines the following variables:
MQAXP ExitParms; /* Exit parameter structure */ MQAXC ExitContext; /* Exit context structure */ PMQHCONN pHconn; /* Ptr to Connection handle */ MQLONG CompCode; /* Completion code */ MQLONG Reason; /* Reason code */
The queue manager then logically calls the exit as follows:
MQ_DISC_EXIT (&ExitParms, &ExitContext, &pHconn, &CompCode, &Reason);
Your exit must match the following C function prototype:
void MQENTRY MQ_DISC_EXIT ( PMQAXP pExitParms, /* Address of exit parameter structure */ PMQAXC pExitContext, /* Address of exit context structure */ PPMQHCONN ppHconn, /* Address of ptr to connection handle */ PMQLONG pCompCode, /* Address of completion code */ PMQLONG pReason); /* Address of reason code qualifying completion code */
MQ_GET_EXIT provides a get exit function to perform before and after MQGET call processing. There are two function identifiers:
The interface to this function is:
MQ_GET_EXIT (&ExitParms, &ExitContext, &Hconn, &Hobj, &pMsgDesc, &pGetMsgOpts, &BufferLength, &pBuffer, &pDataLength, &CompCode, &Reason)
where the parameters are:
If the completion code is MQCC_OK, the only valid value is:
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 queue manager logically defines the following variables:
MQAXP ExitParms; /* Exit parameter structure */ MQAXC ExitContext; /* Exit context structure */ MQHCONN Hconn; /* Connection handle */ MQHOBJ Hobj; /* Object handle */ PMQMD pMsgDesc; /* Ptr to message descriptor */ PMQPMO pGetMsgOpts; /* Ptr to get message options */ MQLONG BufferLength; /* Message buffer length */ PMQBYTE pBuffer; /* Ptr to message buffer */ PMQLONG pDataLength; /* Ptr to data length field */ MQLONG CompCode; /* Completion code */ MQLONG Reason; /* Reason code */
The queue manager then logically calls the exit as follows:
MQ_GET_EXIT (&ExitParms, &ExitContext, &Hconn, &Hobj, &pMsgDesc, &pGetMsgOpts, &BufferLength, &pBuffer, &pDataLength, &CompCode, &Reason)
Your exit must match the following C function prototype:
void MQENTRY MQ_GET_EXIT ( PMQAXP pExitParms, /* Address of exit parameter structure */ PMQAXC pExitContext, /* Address of exit context structure */ PMQHCONN pHconn, /* Address of connection handle */ PPMQHOBJ pHobj, /* Address of object handle */ PPMQMD ppMsgDesc, /* Address of ptr to message descriptor */ PPMQGMO ppGetMsgOpts, /* Address of ptr to get message options */ PMQLONG pBufferLength, /* Address of message buffer length */ PPMQBYTE ppBuffer, /* Address of ptr to message buffer */ PPMQLONG ppDataLength, /* Address of ptr to data length field */ PMQLONG pCompCode, /* Address of completion code */ PMQLONG pReason); /* Address of reason code qualifying completion code */
MQ_INIT_EXIT provides connection level initialization, indicated by setting ExitReason in MQAXP to MQXR_CONNECTION. During the initialization, note the following:
The interface to MQ_INIT_EXIT is:
MQ_INIT_EXIT (&ExitParms, &ExitContext, &CompCode, &Reason)
where the parameters are:
If the completion code is MQCC_OK, the only valid value is:
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.
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 */
MQ_INQ_EXIT provides an inquire exit function to perform before and after MQINQ call processing. Use function identifier MQXF_INQ with exit reasons MQXR_BEFORE and MQXR_AFTER to register before and after MQINQ call exit functions.
The interface to this function is:
MQ_INQ_EXIT (&ExitParms, &ExitContext, &Hconn, &Hobj, &SelectorCount, &pSelectors, &IntAttrCount, &pIntAttrs, &CharAttrLength, &pCharAttrs, &CompCode, &Reason)
where the parameters are:
If the completion code is MQCC_OK, the only valid value is:
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 queue manager logically defines the following variables:
MQAXP ExitParms; /* Exit parameter structure */ MQAXC ExitContext; /* Exit context structure */ MQHCONN Hconn; /* Connection handle */ MQHOBJ Hobj; /* Object handle */ MQLONG SelectorCount; /* Count of selectors */ PMQLONG pSelectors; /* Ptr to array of attribute selectors */ MQLONG IntAttrCount; /* Count of integer attributes */ PMQLONG pIntAttrs; /* Ptr to array of integer attributes */ MQLONG CharAttrLength; /* Length of char attributes array */ PMQCHAR pCharAttrs; /* Ptr to character attributes */ MQLONG CompCode; /* Completion code */ MQLONG Reason; /* Reason code qualifying completion code */
The queue manager then logically calls the exit as follows:
MQ_INQ_EXIT (&ExitParms, &ExitContext, &Hconn, &Hobj, &SelectorCount, &pSelectors, &IntAttrCount, &pIntAttrs, &CharAttrLength, &pCharAttrs, &CompCode, &Reason)
Your exit must match the following C function prototype:
void MQENTRY MQ_INQ_EXIT ( PMQAXP pExitParms, /* Address of exit parameter structure */ PMQAXC pExitContext, /* Address of exit context structure */ PMQHCONN pHconn, /* Address of connection handle */ PMQHOBJ pHobj, /* Address of object handle */ PMQLONG pSelectorCount, /* Address of selector count */ PPMQLONG ppSelectors, /* Address of ptr to array of selectors */ PMQLONG pIntAttrCount; /* Address of count of integer attributes */ PPMQLONG ppIntAttrs, /* Address of ptr to array of integer attributes */ PMQLONG pCharAttrLength, /* Address of character attribute length */ PPMQCHAR ppCharAttrs, /* Address of ptr to character attributes array */ PMQLONG pCompCode, /* Address of completion code */ PMQLONG pReason); /* Address of reason code qualifying completion code */
MQ_OPEN_EXIT provides an open exit function to perform before and after MQOPEN call processing. Use function identifier MQXF_OPEN with exit reasons MQXR_BEFORE and MQXR_AFTER to register before and after MQOPEN call exit functions.
The interface to this function is
MQ_OPEN_EXIT (&ExitParms, &ExitContext, &Hconn, &pObjDesc, &Options, &pHobj, &CompCode, &Reason)
where the parameters are:
If the completion code is MQCC_OK, the only valid value is:
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 queue manager logically defines the following variables:
MQAXP ExitParms; /* Exit parameter structure */ MQAXC ExitContext; /* Exit context structure */ MQHCONN Hconn; /* Connection handle */ PMQOD pObjDesc; /* Ptr to object descriptor */ MQLONG Options; /* Open options */ PMQHOBJ pHobj; /* Ptr to object handle */ MQLONG CompCode; /* Completion code */ MQLONG Reason; /* Reason code */
The queue manager then logically calls the exit as follows:
MQ_OPEN_EXIT (&ExitParms, &ExitContext, &Hconn, &pObjDesc, &Options, &pHobj, &CompCode, &Reason);
Your exit must match the following C function prototype:
void MQENTRY MQ_OPEN_EXIT ( PMQAXP pExitParms, /* Address of exit parameter structure */ PMQAXC pExitContext, /* Address of exit context structure */ PMQHCONN pHconn, /* Address of connection handle */ PPMQOD ppObjDesc, /* Address of ptr to object descriptor */ PMQLONG pOptions, /* Address of open options */ PPMQHOBJ ppHobj, /* Address of ptr to object handle */ PMQLONG pCompCode, /* Address of completion code */ PMQLONG pReason); /* Address of reason code qualifying completion code */
MQ_PUT_EXIT provides a put exit function to perform before and after MQPUT call processing. Use function identifier MQXF_PUT with exit reasons MQXR_BEFORE and MQXR_AFTER to register before and after MQPUT call exit functions.
The interface to this function is:
MQ_PUT_EXIT (&ExitParms, &ExitContext, &Hconn, &Hobj, &pMsgDesc, &pPutMsgOpts, &BufferLength, &pBuffer, &CompCode, &Reason)
where the parameters are:
If the completion code is MQCC_OK, the only valid value is:
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 queue manager logically defines the following variables:
MQAXP ExitParms; /* Exit parameter structure */ MQAXC ExitContext; /* Exit context structure */ MQHCONN Hconn; /* Connection handle */ MQHOBJ Hobj; /* Object handle */ PMQMD pMsgDesc; /* Ptr to message descriptor */ PMQPMO pPutMsgOpts; /* Ptr to put message options */ MQLONG BufferLength; /* Message buffer length */ PMQBYTE pBuffer; /* Ptr to message data */ MQLONG CompCode; /* Completion code */ MQLONG Reason; /* Reason code */
The queue manager then logically calls the exit as follows:
MQ_PUT_EXIT (&ExitParms, &ExitContext, &Hconn, &Hobj, &pMsgDesc, &pPutMsgOpts, &BufferLength, &pBuffer, &CompCode, &Reason)
Your exit must match the following C function prototype:
void MQENTRY MQ_PUT_EXIT ( PMQAXP pExitParms, /* Address of exit parameter structure */ PMQAXC pExitContext, /* Address of exit context structure */ PMQHCONN pHconn, /* Address of connection handle */ PMQHOBJ pHobj, /* Address of object handle */ PPMQMD ppMsgDesc, /* Address of ptr to message descriptor */ PPMQPMO ppPutMsgOpts, /* Address of ptr to put message options */ PMQLONG pBufferLength, /* Address of message buffer length */ PPMQBYTE ppBuffer, /* Address of ptr to message buffer */ PMQLONG pCompCode, /* Address of completion code */ PMQLONG pReason); /* Address of reason code qualifying completion code */
MQ_PUT1_EXIT provides a put one exit function to perform before and after MQPUT1 call processing. Use function identifier MQXF_PUT1 with exit reasons MQXR_BEFORE and MQXR_AFTER to register before and after MQPUT1 call exit functions.
The interface to this function is:
MQ_PUT1_EXIT (&ExitParms, &ExitContext, &Hconn, &pObjDesc, &pMsgDesc, &pPutMsgOpts, &BufferLength, &pBuffer, &CompCode, &Reason)
where the parameters are:
If the completion code is MQCC_OK, the only valid value is:
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 queue manager logically defines the following variables:
MQAXP ExitParms; /* Exit parameter structure */ MQAXC ExitContext; /* Exit context structure */ MQHCONN Hconn; /* Connection handle */ PMQOD pObjDesc; /* Ptr to object descriptor */ PMQMD pMsgDesc; /* Ptr to message descriptor */ PMQPMO pPutMsgOpts; /* Ptr to put message options */ MQLONG BufferLength; /* Message buffer length */ PMQBYTE pBuffer; /* Ptr to message data */ MQLONG CompCode; /* Completion code */ MQLONG Reason; /* Reason code */
The queue manager then logically calls the exit as follows:
MQ_PUT1_EXIT (&ExitParms, &ExitContext, &Hconn, &pObjDesc, &pMsgDesc, &pPutMsgOpts, &BufferLength, &pBuffer, &CompCode, &Reason)
Your exit must match the following C function prototype:
void MQENTRY MQ_PUT1_EXIT ( PMQAXP pExitParms, /* Address of exit parameter structure */ PMQAXC pExitContext, /* Address of exit context structure */ PMQHCONN pHconn, /* Address of connection handle */ PPMQOD ppObjDesc, /* Address of ptr to object descriptor */ PPMQMD ppMsgDesc, /* Address of ptr to message descriptor */ PPMQPMO ppPutMsgOpts, /* Address of ptr to put message options */ PMQLONG pBufferLength, /* Address of message buffer length */ PPMQBYTE ppBuffer, /* Address of ptr to message buffer */ PMQLONG pCompCode, /* Address of completion code */ PMQLONG pReason); /* Address of reason code qualifying completion code */
MQ_SET_EXIT provides an inquire exit function to perform before and after MQSET call processing. Use function identifier MQXF_SET with exit reasons MQXR_BEFORE and MQXR_AFTER to register before and after MQSET call exit functions.
The interface to this function is:
MQ_SET_EXIT (&ExitParms, &ExitContext, &Hconn, &Hobj, &SelectorCount, &pSelectors, &IntAttrCount, &pIntAttrs, &CharAttrLength, &pCharAttr, &CompCode, &Reason)
where the parameters are:
If the completion code is MQCC_OK, the only valid value is:
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 queue manager logically defines the following variables:
MQAXP ExitParms; /* Exit parameter structure */ MQAXC ExitContext; /* Exit context structure */ MQHCONN Hconn; /* Connection handle */ MQHOBJ Hobj; /* Object handle */ MQLONG SelectorCount; /* Count of selectors */ PMQLONG pSelectors; /* Ptr to array of attribute selectors */ MQLONG IntAttrCount; /* Count of integer attributes */ PMQLONG pIntAttrs; /* Ptr to array of integer attributes */ MQLONG CharAttrLength; /* Length of char attributes array */ PMQCHAR pCharAttrs; /* Ptr to character attributes */ MQLONG CompCode; /* Completion code */ MQLONG Reason; /* Reason code qualifying completion code */
The queue manager then logically calls the exit as follows:
MQ_SET_EXIT (&ExitParms, &ExitContext, &Hconn, &Hobj, &SelectorCount, &pSelectors, &IntAttrCount, &pIntAttrs, &CharAttrLength, &pCharAttrs, &CompCode, &Reason)
Your exit must match the following C function prototype:
void MQENTRY MQ_SET_EXIT ( PMQAXP pExitParms, /* Address of exit parameter structure */ PMQAXC pExitContext, /* Address of exit context structure */ PMQHCONN pHconn, /* Address of connection handle */ PMQHOBJ pHobj, /* Address of object handle */ PMQLONG pSelectorCount, /* Address of selector count */ PPMQLONG ppSelectors, /* Address of ptr to array of selectors */ PMQLONG pIntAttrCount; /* Address of count of integer attributes */ PPMQLONG ppIntAttrs, /* Address of ptr to array of integer attributes */ PMQLONG pCharAttrLength, /* Address of character attribute length */ PPMQCHAR ppCharAttrs, /* Address of ptr to character attributes array */ PMQLONG pCompCode, /* Address of completion code */ PMQLONG pReason); /* Address of reason code qualifying completion code */
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:
If the completion code is MQCC_OK, the only valid value is:
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.
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 */
This section provides some general guidance to help you plan your exits, particularly related to handling errors and unexpected events.
If an exit function abnormally terminates after a destructive, out of syncpoint, MQGET call but before the message has been passed to the application, the exit handler can recover from the failure and pass control to the application. In this case, the message might be lost. This is similar to what happens when an application fails immediately after receiving a message from a queue.
The MQGET call might complete with MQCC_FAILED and MQRC_API_EXIT_ERROR.
If a before API call exit function terminates abnormally, the exit handler can recover from the failure and pass control to the application without processing the API call. In this event, the exit function must recover any resources that it owns.
If chained exits are in use, the after API call exits for any before API call exits that had successfully been driven can themselves be driven. The API call might fail with MQCC_FAILED and MQRC_API_EXIT_ERROR.
The following diagram shows the points (eN) at which errors can occur. It is only an example to show how exits behave and should be read together with the following table. In this example, two exit functions are invoked both before and after each API call to show the behavior with chained exits.
Application ErrPt Exit function API call ----------- ----- ------------- -------- Start MQCONN --> e1 MQ_INIT_EXIT e2 before MQ_CONNX_EXIT 1 e3 before MQ_CONNX_EXIT 2 e4 --> MQCONN e5 after MQ_CONNX_EXIT 2 e6 after MQ_CONNX_EXIT 1 e7 <-- MQOPEN --> before MQ_OPEN_EXIT 1 e8 before MQ_OPEN_EXIT 2 e9 --> MQOPEN e10 after MQ_OPEN_EXIT 2 e11 after MQ_OPEN_EXIT 1 e12 <-- MQPUT --> before MQ_PUT_EXIT 1 e13 before MQ_PUT_EXIT 2 e14 --> MQPUT e15 after MQ_PUT_EXIT 2 e16 after MQ_PUT_EXIT 1 e17 <-- MQCLOSE --> before MQ_CLOSE_EXIT 1 e18 before MQ_CLOSE_EXIT 2 e19 --> MQCLOSE e20 after MQ_CLOSE_EXIT 2 e21 after MQ_CLOSE_EXIT 1 e22 <-- MQDISC --> before MQ_DISC_EXIT 1 e23 before MQ_DISC_EXIT 2 e24 --> MQDISC e25 after MQ_DISC_EXIT 2 e26 after MQ_DISC_EXIT 1 e27 <-- end
The following table lists the actions to be taken at each error
point. Only a subset of the error points have been covered, as the
rules shown here can apply to all others. It is the actions that
specify the intended behavior in each case.
Table 12. API exit errors and appropriate actions to take
ErrPt | Description | Actions |
---|---|---|
e1 | Error during exit execution environment setup. |
|
e2 | MQ_INIT_EXIT function completes with:
|
|
e3 | Before MQ_CONNX_EXIT 1 function completes with:
|
|
e4 | Before MQ_CONNX_EXIT 2 function completes with:
|
|
e5 | MQCONN call fails. |
|
e6 | After MQ_CONNX_EXIT 2 function completes with:
|
|
e7 | After MQ_CONNX_EXIT 1 function completes with:
|
|
e8 | Before MQ_OPEN_EXIT 1 function completes with:
|
|
e9 | Before MQ_OPEN_EXIT 2 function completes with:
|
|
e10 | MQOPEN call fails |
|
e11 | After MQ_OPEN_EXIT 2 function completes with:
|
|
e25 | After MQ_DISC_EXIT 2 function completes with:
|
|
Notes:
If the ExitResponse field is set to a value other than one of the supported values, the following actions apply:
If an exit function sets the ExitResponse2 field to a value other than one of the supported values, a value of MQXR2_DEFAULT_CONTINUATION is assumed instead.