IBM MQ API exit parameter structure (MQAXP)

The MQAXP structure, an external control block, is used as an input or output parameter to the API exit. This topic also gives information about how queue managers process exit functions.

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 */
  /* Ver:1 */
  MQHMSG    ExitMsgHandle      /* Exit message handle
  /* Ver:2 */
};
The following parameter list is passed when functions in an API exit are invoked:

    StrucId (MQCHAR4) - input
    The exit parameter structure identifier, with a value of:
    MQAXP_STRUC_ID.
    
    The exit handler sets this field on entry to each exit function.

    Version (MQLONG) - input
    The structure version number, with a value of:

      MQAXP_VERSION_1
      Version 1 API exit parameter structure.

      MQAXP_VERSION_2
      Version 2 API exit parameter structure.

      MQAXP_CURRENT_VERSION
      Current version number for the API exit parameter structure.

    The exit handler sets this field on entry to each exit function.

    ExitId (MQLONG) - input
    The exit identifier, set on entry to the exit routine, indicating the type of exit:

      MQXT_API_EXIT
      API exit.

    ExitReason (MQLONG) - input
    The reason for invoking the exit, set on entry to each exit function:

      MQXR_CONNECTION
      The exit is being invoked to initialize itself before an MQCONN or MQCONNX call, or to end itself after an MQDISC call.

      MQXR_BEFORE
      The exit is being invoked before executing an API call, or before converting data on an MQGET.

      MQXR_AFTER
      The exit is being invoked after executing an API call.

    ExitResponse (MQLONG) - output
    The response from the exit, initialized on entry to each exit function to:

      MQXCC_OK
      Continue normally.

    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:

      MQXCC_OK
      The exit function completed successfully. Continue normally.

      This value can be set by all MQXR_* exit functions. ExitResponse2 is used to decide whether to invoke exit functions later in the chain.

      MQXCC_FAILED
      The exit function failed because of an error. This value can be set by all MQXR_* exit functions. The queue manager sets CompCode to MQCC_FAILED, and Reason to:

      • MQRC_API_EXIT_INIT_ERROR if the function is MQ_INIT_EXIT
      • MQRC_API_EXIT_TERM_ERROR if the function is MQ_TERM_EXIT
      • MQRC_API_EXIT_ERROR for all other exit functions

      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.

      MQXCC_SUPPRESS_FUNCTION
      Suppress IBM MQ API function.

      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 to invoke exit functions later in the chain.

      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.

      MQXCC_SKIP_FUNCTION
      Skip IBM MQ API function.

      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 to invoke exit functions later in the chain.

      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.

      MQXCC_SUPPRESS_EXIT
      Suppress all exit functions belonging to the set of exits.

      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 about the interaction between ExitResponse and ExitResponse2, and its effect on exit processing, see How queue managers process exit functions.

    ExitResponse2 (MQLONG) - output
    This is a secondary exit response code that qualifies the primary exit response code for MQXR_BEFORE exit functions. It is initialized to:
    MQXR2_DEFAULT_CONTINUATION
    
    on entry to an IBM MQ API call exit function. It can then be set to one of the values:

      MQXR2_DEFAULT_CONTINUATION
      Whether to continue with the next exit in the chain, depending on the value of ExitResponse.

      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.

      MQXR2_SUPPRESS_CHAIN
      Suppress 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.

      MQXR2_CONTINUE_CHAIN
      Continue with the next exit in the chain.

    For information about the interaction between ExitResponse and ExitResponse2, and its effect on exit processing, see How queue managers process exit functions.

    Feedback (MQLONG) - input/output
    Communicate feedback codes between exit function invocations. This is initialized to:
    MQFB_NONE (0)
    
    before invoking 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.

    APICallerType (MQLONG) - input
    The API caller type, indicating whether the IBM MQ API caller is external or internal to the queue manager: MQXACT_EXTERNAL or MQXACT_INTERNAL.

    ExitUserArea (MQBYTE16) - input/output
    A user area, available to all the exits associated with a particular ExitInfoObject. It is initialized to MQXUA_NONE (binary zeros for the length of the ExitUserArea) before invoking the first exit function (MQ_INIT_EXIT) for the hconn. From then on, any changes made to this field by an exit function are preserved across invocations of functions of the same exit.

    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.

    ExitData (MQCHAR32) - input
    Exit data, set on input to each exit function to the 32 characters of exit-specific data that is provided in the exit. If you define no value in the exit this field is all blanks.

    The length of this field is given by MQ_EXIT_DATA_LENGTH.

    ExitInfoName (MQCHAR48) - input
    The exit information name, set on input to each exit function to the ApiExit_name specified in the exit definitions in the stanzas.

    ExitPDArea (MQBYTE48) - input/output
    A problem determination area, initialized to MQXPDA_NONE (binary zeros for the length of the field) for each invocation of an exit function.

    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 IBM 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.

    QMgrName (MQCHAR48) - input
    The name of the queue manager the application is connected to, that has invoked an exit as a result of processing an IBM MQ API call.

    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 queue manager to which the application is connected, whether the application is server or client.

    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.

    ExitChainAreaPtr (PMQACH) - input/output
    This is used to communicate data across invocations of different exits in a chain. It is set to a NULL pointer before invoking the first function (MQ_INIT_EXIT with ExitReason MQXR_CONNECTION) of the first exit in a chain of exits. The value returned by the exit on one invocation is passed on to the next invocation.

    Refer to The exit chain area and exit chain area header (MQACH) for more details about how to use the exit chain area.

    Hconfig (MQHCONFIG) - input
    The configuration handle, representing the set of functions being initialized. This value is generated by the queue manager on the MQ_INIT_EXIT function, and is later passed to the API exit function. It is set on entry to each exit function.

    We can use Hconfig as a pointer to the MQIEP structure to make MQI and DCI calls. We must check that the first 4 bytes of HConfig match the StrucId of the MQIEP structure before using the HConfig parameter as a pointer to the MQIEP structure.

    Function (MQLONG) - input
    The function identifier, valid values for which are the MQXF_* constants described in External constants.

    The exit handler sets this field to the correct value, on entry to each exit function, depending on the IBM MQ API call that resulted in the exit being invoked.

    ExitMsgHandle (MQHMSG) - input/output
    When Function is MQXF_GET and ExitReason is MQXR_AFTER, a valid message handle is returned in this field allowing the API exit access to the message descriptor fields and any other properties matching the ExitProperties string specified in the MQXEPO structure when registering the API exit.

    Any non-message descriptor properties that are returned in the ExitMsgHandle will not be available from the MsgHandle in the MQGMO structure if one was specified, or in the message data.

    When Function is MQXF_GET and ExitReason is MQXR_BEFORE, if the exit program sets this field to MQHM_NONE then it will suppress the populating of the ExitMsgHandle properties.

    This field is not set if Version is less then MQAXP_VERSION_2.


How queue managers process exit functions

The processing performed by the queue manager on return from an exit function depends on both ExitResponse and ExitResponse2.

Table 1 summarizes the possible combinations and their effects for an MQXR_BEFORE exit function, showing:

  • Who sets the CompCode and Reason parameters of the API call
  • Whether the remaining exit functions in the MQXR_BEFORE chain and the matching exit functions in the MQXR_AFTER chain are invoked
  • Whether the API call is invoked

For an MQXR_AFTER exit function:

  • CompCode and Reason are set in the same way as MQXR_BEFORE
  • ExitResponse2 is ignored (the remaining exit functions in the MQXR_AFTER chain are always invoked)
  • MQXCC_SUPPRESS_FUNCTION and MQXCC_SKIP_FUNCTION are not valid

For an MQXR_CONNECTION exit function:

  • CompCode and Reason are set in the same way as MQXR_BEFORE
  • ExitResponse2 is ignored
  • MQXCC_SUPPRESS_FUNCTION, MQXCC_SKIP_FUNCTION, MQXCC_SUPPRESS_EXIT are not valid

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).

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


How clients process exit functions

In general, clients process exit functions in the same way that server applications do, and the QMgrName attribute in this structure applies whether the function is on a server or a client.

However, the client has no concept of the mqs.ini file, so the ApiExitCommon and APIExitTemplate stanzas do not apply. Only the ApiExitLocal stanza applies, and this stanza is configured in the mqclient.ini file.

Parent topic: API exit reference