Channel-exit programs are called at defined places in the processing carried out by MCA programs.
Some of these user-exit programs work in complementary pairs. For example, if a user-exit program is called by the sending MCA to encrypt the messages for transmission, the complementary process must be functioning at the receiving end to reverse the process.
The different types of channel-exit program are described below. Table 52 shows the types of channel exit that are available for each
channel type.
Table 52. Channel exits available for each channel type
Channel Type | Message exit | Message- retry exit | Receive exit | Security exit | Send exit | Auto- definition exit | Transport- retry exit |
---|---|---|---|---|---|---|---|
Sender channel | Yes |
| Yes | Yes | Yes |
| Yes |
Server channel | Yes |
| Yes | Yes | Yes |
| Yes |
Cluster- sender channel | Yes |
| Yes | Yes | Yes | Yes |
|
Receiver channel | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
Requester channel | Yes | Yes | Yes | Yes | Yes |
| Yes |
Cluster- receiver channel | Yes | Yes | Yes | Yes | Yes | Yes |
|
Client- connection channel |
|
| Yes | Yes | Yes |
|
|
Server- connection channel |
|
| Yes | Yes | Yes | Yes |
|
|
If you are going to run channel exits on a client, you cannot use the MQSERVER environment variable. Instead, create and reference a client channel definition table as described in the WebSphere MQ Clients book.
On startup, the MCAs exchange a startup dialog to synchronize processing. Then they switch to a data exchange that includes the security exits; these must end successfully for the startup phase to complete and to allow messages to be transferred.
The security check phase is a loop, as shown in Figure 120.
Figure 120. Security exit loop
During the message transfer phase, the sending MCA gets messages from a transmission queue, calls the message exit, calls the send exit, and then sends the message to the receiving MCA, as shown in Figure 121.
Figure 121. Example of a send exit at the sender end of message channel
Figure 122. Example of a receive exit at the receiver end of message channel
The receiving MCA receives a message from the communications link, calls the receive exit, calls the message exit, and then puts the message on the local queue, as shown in Figure 122. (The receive exit can be called more than once before the message exit is called.)
You can use security exit programs to verify that the partner at the other end of a channel is genuine.
Channel security exit programs are called at the following places in an MCA's processing cycle:
A requester channel never gets called with MQXCC_INIT_SEC. The channel notifies the server that it has a security exit program, and the server then has the opportunity to initiate a security exit. If it does not have one, it sends a null security flow to allow the requester to call its exit program.
WebSphere MQ for AIX, HP-UX, Linux, Solaris, and Windows, and MQSeries V5.1 for Compaq Tru64 UNIX, and OS/2 Warp, and the WebSphere MQ client for Windows 95 and Windows 98 supply a security exit program that uses the DCE security services. See Supplied channel-exit programs using DCE security services.
Examples of the data exchanged by security-exit programs are illustrated in figures Figure 123 through Figure 126. These examples show the sequence of events that occur involving the receiver's security exit (left-hand column) and the sender's security exit (right-hand column). Successive rows in the figures represent the passage of time. In some cases, the events at the receiver and sender are not correlated, and therefore can occur at the same time or at different times. In other cases, an event at one exit program results in a complementary event occurring later at the other exit program. For example, in Figure 123:
Figure 123. Sender-initiated exchange with agreement
Figure 124. Sender-initiated exchange with no agreement
Figure 125. Receiver-initiated exchange with agreement
Figure 126. Receiver-initiated exchange with no agreement
The channel security exit program is passed an agent buffer containing the security data, excluding any transmission headers, generated by the security exit. This may be any suitable data so that either end of the channel is able to perform security validation.
The security exit program at both the sending and receiving end of the message channel may return one of four response codes to any call:
Notes:
You can use the send and receive exits to perform tasks such as data compression and decompression. WebSphere MQ for AIX, iSeries, HP-UX, Linux, Solaris, z/OS without CICS, and Windows, and MQSeries V5.1 for Compaq Tru64 UNIX, and OS/2 Warp, and with WebSphere MQ clients, you can specify a list of send and receive exit programs to be run in succession.
Channel send and receive exit programs are called at the following places in an MCA's processing cycle:
There may be many transmissions for one message transfer, and there could be many iterations of the send and receive exit programs before a message reaches the message exit at the receiving end.
The channel send and receive exit programs are passed an agent buffer containing the transmission data as sent or received from the communications link. For send exit programs, the first eight bytes of the buffer are reserved for use by the MCA, and must not be changed. If the program returns a different buffer, then these first eight bytes must exist in the new buffer. The format of data presented to the exit programs is not defined.
A good response code must be returned by send and receive exit programs. Any other response will cause an MCA abnormal end (abend).
WebSphere MQ for AIX, HP-UX, Linux, Solaris, and Windows, and MQSeries V5.1 for Compaq Tru64 UNIX, and OS/2 Warp, and the WebSphere MQ client for Windows 95 and Windows 98 supply send and receive exit programs that use the DCE encryption security services. See Supplied channel-exit programs using DCE security services.
Notes:
You should code your send and receive exits in such a way that the receive exit can check that the data it is receiving has been processed by the corresponding send exit. The recommended way to do this is to code your exit programs so that:
When using security exits, if the channel is ended by the security exit it is possible that a send exit may be called without the corresponding receive exit. One way to prevent this from being a problem is to code the security exit to set a flag, in MQCD.SecurityUserData or MQCD.SendUserData, for example, when the exit decides to end the channel. Then the send exit should check this field, and process the data only if the flag is not set. This prevents the send exit from unnecessarily altering the data, and thus prevents any conversion errors that could occur if the security exit received altered data.
Table 53 shows the data that appears in byte 10 of the channel flow when an API call is being processed.
Table 53. Identifying API calls
API call | Value of byte 10 |
---|---|
MQCONN request (1, 2) | X'81' |
MQCONN reply (1, 2) | X'91' |
MQDISC request (1) | X'82' |
MQDISC reply (1) | X'92' |
MQOPEN request (3) | X'83' |
MQOPEN reply (3) | X'93' |
MQCLOSE request | X'84' |
MQCLOSE reply | X'94' |
MQGET request (4) | X'85' |
MQGET reply (4) | X'95' |
MQPUT request (4) | X'86' |
MQPUT reply (4) | X'96' |
MQPUT1 request (4) | X'87' |
MQPUT1 reply (4) | X'97' |
MQSET request | X'88' |
MQSET reply | X'98' |
MQINQ request | X'89' |
MQINQ reply | X'99' |
MQCMIT request | X'8A' |
MQCMIT reply | X'9A' |
MQBACK request | X'8B' |
MQBACK reply | X'9B' |
|
You can use send and receive exits to transform the data before transmission. Channel send exit programs can add their own data about the transformation by reserving space in the transmission buffer. This data is processed by the receive exit program and then removed from the buffer. For example, you might want to encrypt the data and add a security key for decryption.
Channel exit programs are passed an MQCXP parameter block. A new field, ExitSpace, is added to the MQCXP structure, as described in MQCXP - Channel exit parameter. This parameter is not supported on z/OS.
When the send exit program is called for initialization, set the ExitSpace field to the number of bytes to be reserved. ExitSpace can be set only during initialization, that is when ExitReason has the value MQXR_INIT. When the send exit is invoked immediately before transmission, with ExitReason set to MQXR_XMIT, ExitSpace bytes are reserved in the transmission buffer.
The send exit need not use all of the reserved space. It can use
less than ExitSpace bytes or, if the transmission buffer is not full,
the exit can use more than the amount reserved. When setting the value
of ExitSpace, you must leave at least 1 KB for message data in the
transmission buffer. Note that channel performance can be affected if
reserved space is used for large amounts of data.
What happens at the receiving end of the channel
Channel receive exit programs must be set up to be compatible with the corresponding send exits. Receive exits must know the number of bytes in the reserved space and must remove the data in that space.
You can specify a list of send and receive exit programs to be run in succession. WebSphere MQ maintains a total for the space reserved by all of the send exits. This total space must leave at least 1 KB for message data in the transmission buffer.
The following example shows how space is allocated for three send exits, called in succession:
You can use the channel message exit for the following:
WebSphere MQ for AIX, iSeries, HP-UX, Linux, Solaris, z/OS without CICS, and Windows, and MQSeries V5.1 for Compaq Tru64 UNIX, and OS/2 Warp, and with WebSphere MQ clients, you can specify a list of message exit programs to be run in succession.
Channel message exit programs are called at the following places in an MCA's processing cycle:
The message exit is passed an agent buffer containing the transmission queue header, MQXQH, and the application message text as retrieved from the queue. (The format of MQXQH is given in the WebSphere MQ Application Programming Reference book.) If you use reference messages, that is messages that contain only a header which points to some other object that is to be sent, the message exit recognizes the header, MQRMH. It identifies the object, retrieves it in whatever way is appropriate appends it to the header, and passes it to the MCA for transmission to the receiving MCA. At the receiving MCA, another message exit recognizes that this is a reference message, extracts the object, and passes the header on to the destination queue. See the WebSphere MQ Application Programming Guide for more information about reference messages and some sample message exits that handle them.
Message exits can return the following responses:
Notes:
Therefore, it is possible to issue syncpoint MQI calls from a channel message exit program.
WebSphere MQ for AIX, HP-UX, Linux, Solaris, and Windows, and MQSeries V5.1 for Compaq Tru64 UNIX, and OS/2 Warp supplies a message exit program that uses the DCE security services. See Supplied channel-exit programs using DCE security services.
The channel message-retry exit is called when an attempt to open the target queue is unsuccessful. You can use the exit to determine under which circumstances to retry, how many times to retry, and how frequently. (This exit is not available on WebSphere MQ for z/OS.)
This exit is also called at the receiving end of the channel at MCA initiation and termination.
The channel message-retry exit is passed an agent buffer containing the transmission queue header, MQXQH, and the application message text as retrieved from the queue. The format of MQXQH is given in the WebSphere MQ Application Programming Reference book.
The exit is invoked for all reason codes; the exit determines for which reason codes it wants the MCA to retry, for how many times, and at what intervals. (The value of the message-retry count set when the channel was defined is passed to the exit in the MQCD, but the exit can ignore this.)
The MsgRetryCount field in MQCXP is incremented by the MCA each time the exit is invoked, and the exit returns either MQXCC_OK with the wait time contained in the MsgRetryInterval field of MQCXP, or MQXCC_SUPPRESS_FUNCTION. Retries continue indefinitely until the exit returns MQXCC_SUPPRESS_FUNCTION in the ExitResponse field of MQCXP. See MQCXP - Channel exit parameter for information about the action taken by the MCA for these completion codes.
If all the retries are unsuccessful, the message is written to the dead-letter queue. If there is no dead-letter queue available, the channel stops.
If you do not define a message-retry exit for a channel and a failure occurs that is likely to be temporary, for example MQRC_Q_FULL, the MCA uses the message-retry count and message-retry intervals set when the channel was defined. If the failure is of a more permanent nature and you have not defined an exit program to handle it, the message is written to the dead-letter queue.
The channel auto-definition exit can be called when a request is received to start a receiver or server-connection channel but no channel definition exists. The exit applies to WebSphere MQ for AIX, HP-UX, iSeries, Solaris, and Windows, and MQSeries for Compaq Tru64 UNIX, and OS/2 Warp V5.1. You can use it to modify the supplied default definition for an automatically defined receiver or server-connection channel, SYSTEM.AUTO.RECEIVER or SYSTEM.AUTO.SVRCON. See Auto-definition of receiver and server-connection channels for a description of how channel definitions can be created automatically.
The channel auto-definition exit can also be called when a request is received to start a cluster-sender channel. It can be called for cluster-sender and cluster-receiver channels to allow definition modification for this instance of the channel. In this case, the exit applies to WebSphere MQ for z/OS as well as WebSphere MQ for AIX, HP-UX, iSeries, Solaris, and Windows, and MQSeries for Compaq Tru64 UNIX, and OS/2 Warp V5.1. For more information about this, see the WebSphere MQ Queue Manager Clusters book.
As with other channel exits, the parameter list is:
MQ_CHANNEL_AUTO_DEF_EXIT (ChannelExitParms, ChannelDefinition)
ChannelExitParms are described in MQCXP - Channel exit parameter. ChannelDefinition is described in MQCD - Channel definition.
MQCD contains the values that are used in the default channel definition if they are not altered by the exit. The exit may modify only a subset of the fields; see MQ_CHANNEL_AUTO_DEF_EXIT - Channel auto-definition exit. However, attempting to change other fields does not cause an error.
The channel auto-definition exit returns a response of either MQXCC_OK or MQXCC_SUPPRESS_FUNCTION. If neither of these is returned, the MCA continues processing as though MQXCC_SUPPRESS_FUNCTION were returned. That is, the auto-definition is abandoned, no new channel definition is created and the channel cannot start.
The transport-retry exit applies to WebSphere MQ for AIX, V5.3 and is supported on UDP only. It allows you to write a C-language retry exit. The exit allows your application to suspend data being sent on a channel when communication is not possible (for example, when a mobile user is traveling through a tunnel or is temporarily out of range of a transmitter).
The transport-retry exit can be associated with a monitor program that can assess whether the IP connection is available for sending data. The exit has to be built into a library that is included in the path in which you are operating.
The exit is normally called before a datagram is about to be sent but is also called to provide other useful signals.
The retry exit is called under five different conditions:
If you want to postpone sending a datagram in response to an ExitReason of MQXR_RETRY, you need to block returning from the exit until it is safe to send the datagram. In all other cases, the return from the exit should be immediate.
There are three possible return codes that can be set when returning from the exit:
The transport-retry exit name can be defined by the user, who can also change the name of the library that contains the exit. You configure the retry exit by editing the qm.ini file. For more information about editing these files, see the WebSphere MQ System Administration Guide book.