channel exits, MQSendExit, MQReceiveExit, MQSecurityExit" /> Use channel exits

 

Using channel exits

When you use a fully-managed connection,

WebSphere MQ .NET allows you to provide your own send, receive, and security exits.

To implement an exit, you define a new .NET class that implements the appropriate interface. Three exit interfaces are defined in the WebSphere MQ package:

Note:
User exits written using this interface are not supported as channel exits in the unmanaged environment (that is, when either the C Client or C XA Client are being used).

The following sample defines a class that implements all three:

class MyMQExits 

:

MQSendExit, MQReceiveExit, MQSecurityExit { // This method comes from the send exit byte[] SendExit(MQChannelExit channelExitParms, MQChannelDefinition channelDefinition, byte[] dataBuffer ref int dataOffset ref int dataLength ref int dataMaxLength) { // fill in the body of the send exit here } // This method comes from the receive exit byte[] ReceiveExit(MQChannelExit channelExitParms, MQChannelDefinition channelDefinition, byte[] dataBuffer ref int dataOffset ref int dataLength ref int dataMaxLength) { // fill in the body of the receive exit here } // This method comes from the security exit byte[] SecurityExit(MQChannelExit channelExitParms, MQChannelDefinition channelDefParms, byte[] dataBuffer ref int dataOffset ref int dataLength ref int dataMaxLength) { // fill in the body of the security exit here } }

Each exit is passed an MQChannelExit and an MQChannelDefinition object instance. These objects represent the MQCXP and MQCD structures defined in the procedural interface.

The data to be sent by a send exit, and the data received in a security or receive exit is specified using the exit's parameters.

On entry, the data at offset dataOffset with length dataLength in the byte array dataBuffer is the data that is about to be sent by a send exit, and the data received in a security or receive exit. The parameter dataMaxLength gives the maximum length (from dataOffset) available to the exit in dataBuffer.

Note: For a security exit, it is possible for the dataBuffer to be null, if this is the first time the exit is called or the partner end elected to send no data.

On return, the value of dataOffset and dataLength should be set to point to the offset and length within the returned byte array that the .NET classes should then use. For a send exit, this indicates the data that it should send, and for a security or receive exit, the data that should be interpreted. The exit should normally return a byte array; exceptions are a security exit which could elect to send no data, and any exit called with the INIT or TERM reasons. The simplest form of exit that can be written therefore is one which does nothing more than return dataBuffer:

The simplest possible exit body is:

{
  return dataBuffer;
}


csqzav0538