WebSphere MQ classes for Java allows you to provide your own send, receive, and security exits.
To implement an exit, you define a new Java(TM) class that implements the appropriate interface. Three exit interfaces are defined in the WebSphere(R) MQ package:
Any SSL encryption defined for a connection is performed after the send exit has been invoked. Similarly, decryption is performed before the receive or security exits are invoked.
The following sample defines a class that implements all three:
class MyMQExits implements MQSendExit, MQReceiveExit, MQSecurityExit { // 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 } }
Each exit is passed an MQChannelExit and an MQChannelDefinition object instance. These objects represent the MQCXP and MQCD structures defined in the procedural interface.
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.length indicates the length of the array.
For the send and security exits, your exit code should return the byte array that you want to send to the server. For a receive exit, your exit code must return the modified data that you want WebSphere MQ classes for Java to interpret.
The simplest possible exit body is:
{ return agentBuffer; }
If a channel exit is written in Java, no user data can be passed to the exit when it is called.
If your program is to run as a downloaded Java applet, the security restrictions that apply mean that you cannot read or write any local files. If your exit needs a configuration file, you can place the file on the Web and use the java.net.URL class to download it and examine its contents.
Having defined a class that implements the MQSecurityExit interface, an application can use the security exit by assigning an instance of the class to the MQEnvironment.securityExit field before creating an MQQueueManager object. An application can use a send or a receive exit in a similar way. For example, the following code fragment shows you how to use the security, send, and receive exits that are implemented in the class MyMQExits, which was defined previously:
MyMQExits myexits = new MyMQExits(); MQEnvironment.securityExit = myexits; MQEnvironment.sendExit = myexits; MQEnvironment.receiveExit = myexits; : MQQueueManager jupiter = new MQQueueManager("JUPITER");
If your application uses a client channel definition table to connect to a queue manager, see Using a client channel definition table.
A WebSphere MQ base Java application can use channel exits that are written in a language other than Java. Three classes are provided for this purpose:
To use a security exit that is not written in Java, an application must first create an MQExternalSecurityExit object. The application specifies, as parameters on the MQExternalSecurityExit constructor, the name of the library containing the security exit, the name of the entry point for the security exit, and the user data to be passed to the security exit when it is called. The application can then assign the MQExternalSecurityExit object to the MQEnvironment.securityExit field before creating an MQQueueManager object. The MQExternalSecurityExit object contains all the information required to construct the MQCXP and MQCD structures that are passed to the security exit when it is called.
An application can use a send or a receive exit that is not written in Java in a way similar to that just described for a security exit.
For information about how to write a channel exit in a language other than Java, see WebSphere MQ Intercommunication.
A WebSphere MQ base Java application can use a sequence of channel send or receive exits that are run in succession. Two classes are provided for this purpose:
To use a sequence of send exits, an application must create a list of objects, where each object is one of the following:
The application creates an MQSendExitChain object by passing this list of objects as a parameter on the constructor. The application can then assign the MQSendExitChain object to the MQEnvironment.sendExit field before creating an MQQueueManager object.
An application can use a sequence of receive exits in a way similar to that just described for a sequence of send exits.
Notices |
Downloads |
Library |
Support |
Feedback
![]() ![]() |
csq77chex |