Passing data to channel exits in IBM MQ classes for Java

We can pass data to channel exits and return data from channel exits to our application.


The agentBuffer parameter

For a send exit, the agentBuffer parameter contains the data that is about to be sent. For a receive exit or a security exit, the agentBuffer parameter contains the data that has just been received. You do not need a length parameter, because the expression agentBuffer.limit() indicates the length of the array.

For the send and security exits, your exit code must return the data to send to the server. For a receive exit, your exit code must return the modified data that you want IBM MQ to interpret.

The simplest possible exit body is:
{ return agentBuffer; }

Channel exits are called with a buffer that has a backing array. For best performance, the exit should return a buffer with a backing array.


User data

If an application connects to a queue manager by setting channelSecurityExit, channelSendExit, or channelReceiveExit, 32 bytes of user data can be passed to the appropriate channel exit class when it is called, using the channelSecurityExitUserData, channelSendExitUserData, or channelReceiveExitUserData fields. This user data is available to the channel exit class but is refreshed each time the exit is called. Any changes made to the user data in the channel exit will therefore be lost. If you want to make persistent changes to data in a channel exit, use the MQCXP exitUserArea. Data in this field is maintained between invocations of the exit.

If the application sets securityExit, sendExit, or receiveExit, no user data can be passed to these channel exit classes.

If an application uses a client channel definition table (CCDT) to connect to a queue manager, any user data specified in a client connection channel definition is passed to channel exit classes when they are called. For more information about using a client channel definition table, see Use a client channel definition table with IBM MQ classes for Java.