Connect and connect extension - MQ_CONNX_EXIT
MQ_CONNX_EXIT provides connection exit function to perform before and after MQCONN processing, and connection extension exit function to perform before and after MQCONNX processing.
The same interface, as described here, 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 IBM MQ API calls before the client state is fully known. These API calls call the API exit functions 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 IBM MQ API calls, as the correct environment has not been set up at this time.
An MQ_CONNX_EXIT cannot call MQDISC from an API exit call for the connection for which it is being called. This restriction is applicable to both client and server API exits.
The interface to MQCONN and MQCONNX is identical:MQ_CONNX_EXIT (&ExitParms, &ExitContext, &pQMgrName, &pConnectOpts, &pHconn, &CompCode, &Reason);where the parameters are:
- ExitParms (MQAXP) - input/output
- Exit parameter structure.
- ExitContext (MQAXC) - input/output
- Exit context structure.
- pQMgrName (PMQCHAR) - input
- Pointer to the queue manager name supplied on the MQCONNX call. The exit must not change this name on the MQCONN or MQCONNX call.
- pConnectOpts (PMQCNO) - input/output
- Pointer to the options that control the action of the MQCONNX call.
See MQCNO - Connect options for details.
For exit function MQXF_CONN, pConnectOpts points to the default connect options structure (MQCNO_DEFAULT).
- pHconn (PMQHCONN) - input
- Pointer to the connection handle.
- CompCode (MQLONG) - input/output
- Completion code, valid values for which are:
- MQCC_OK
- Successful completion.
- MQCC_WARNING
- Warning (partial 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 or MQCC_WARNING, the exit function can set the reason code field to any valid MQRC_* value.
C language invocation
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 */
Usage notes
- The MQ_CONNX_EXIT function interface described here is used for both the MQCONN call and the MQCONNX call. However, separate entry points are defined for these two calls. To intercept both calls, the MQXEP call must be used at least twice - once with function identifier MQXF_CONN, and again with MQXF_CONNX.
Because the MQ_CONNX_EXIT interface is the same for MQCONN and MQCONNX, a single exit function can be used for both calls; the Function field in the MQAXP structure indicates which call is in progress. Alternatively, the MQXEP call can be used to register different exit functions for the two calls.
- When a message channel agent (MCA) responds to an inbound client connection, the MCA can issue a number of MQ calls before the client state is fully known. These MQ calls result in the API exit functions being invoked with the MQAXC structure containing data relating to the MCA, and not to the client (for example, user identifier and connection name). However, once the client state is fully known, subsequent MQ calls result in the API exit functions being invoked with the appropriate client data in the MQAXC structure.
- All MQXR_BEFORE exit functions are invoked before any parameter validation is performed by the queue manager. The parameters might therefore be invalid (including invalid pointers for the addresses of parameters).
The MQ_CONNX_EXIT function is invoked before any authorization checks are performed by the queue manager.
- The exit function must not change the name of the queue manager specified on the MQCONN or MQCONNX call. If the name is changed by the exit function, the results are undefined.
- An MQXR_BEFORE exit function for the MQ_CONNX_EXIT cannot issue MQ calls other than MQXEP.
Parent topic: Exit functions