Creating a channel exit in IBM MQ classes for Java
You can provide your own channel exits by defining a Java class that implements an appropriate interface.
- WMQSendExit
- WMQReceiveExit
- WMQSecurityExit
Any TLS encryption defined for a connection is performed after send and security exits have been invoked. Similarly, decryption is performed before receive and security exits are invoked.
public class MyMQExits implements
WMQSendExit, WMQReceiveExit, WMQSecurityExit {
// Default constructor
public MyMQExits(){
}
// This method comes from the send exit interface
public ByteBuffer channelSendExit(
MQCXP channelExitParms,
MQCD channelDefinition,
ByteBuffer agentBuffer)
{
// Fill in the body of the send exit here
}
// This method comes from the receive exit interface
public ByteBuffer channelReceiveExit(
MQCXP channelExitParms,
MQCD channelDefinition,
ByteBuffer agentBuffer)
{
// Fill in the body of the receive exit here
}
// This method comes from the security exit interface
public ByteBuffer channelSecurityExit(
MQCXP channelExitParms,
MQCD channelDefinition,
ByteBuffer agentBuffer)
{
// Fill in the body of the security exit here
}
}
Each exit is passed an MQCXP object and an MQCD object. These objects represent the MQCXP and MQCD structures defined in the procedural interface.
Any exit class you write must have a constructor. This can be either the default constructor or one that takes a string argument. If it takes a string then the user data will be passed into the exit class when it is created. If the exit class contains both a default constructor and a single argument constructor, the single argument constructor has priority.
For the send and security exits, your exit code must return the data that you want to send to the server. For a receive exit, your exit code must return the modified data that you want IBM MQ to interpret.
{ return agentBuffer; }
Do not close the queue manager from within a channel exit.
Using existing channel exit classes
public class MyMQExits implements MQSendExit, MQReceiveExit, MQSecurityExit {
// Default constructor
public MyMQExits(){
}
// This method comes from the send exit
public byte[] sendExit(MQChannelExit channelExitParms,
MQChannelDefinition channelDefParms,
byte agentBuffer[])
{
// Fill in the body of the send exit here
}
// This method comes from the receive exit
public byte[] receiveExit(MQChannelExit channelExitParms,
MQChannelDefinition channelDefParms,
byte agentBuffer[])
{
// Fill in the body of the receive exit here
}
// This method comes from the security exit
public byte[] securityExit(MQChannelExit channelExitParms,
MQChannelDefinition channelDefParms,
byte agentBuffer[])
{
// Fill in the body of the security exit here
}
}