Using the MQSeries Control Exit Implementation

The MQSeries control allows you to create your own send, receive, and security exits.

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

Notes: User Exits are supported for TCP connections only; they are not supported for bindings connections.

User Exits are used to modify the data that is transmitted between the MQSeries queue manager and the MQSeries client application. This data is in the form of MQSeries headers and does not involve the contents of the actual message being put and received from the queue.

Implementing MQSeries Exits

To implement MQSeries Exits, perform the following tasks:

  1. Create the Java class that implements the com.ibm.mq.MQSendExit, com.ibm.mq.MQReceiveExit, and com.ibm.mq.MQSecurity interfaces for the send, receive, and security exits, as shown in the following example:
  2. package com.bea.UserExit;
    import com.ibm.mq.*;
    public class MQUserExit implements MQSendExit, MQReceiveExit, MQSecurityExit {
    public MQUserExit()
    {
    }
    public byte[] sendExit(MQChannelExit channelExit,MQChannelDefinition channelDefnition,byte[] agentBuffer)
    {
    return agentBuffer;
    }
    public byte[] receiveExit(MQChannelExit channelExit,MQChannelDefinition channelDefnition,byte[] agentBuffer)
    {
    return agentBuffer;
    }
    public byte[] securityExit(MQChannelExit channelExit,MQChannelDefinition channelDefnition,byte[] agentBuffer)
    {
    return agentBuffer;
    }
    }

    You may implement these interfaces in a single class or in separate classes, as required.

    For an MQSendExit, the agentBuffer parameter contains the data to be sent. For an MQReceiveExit or an MQSecurityExit, the agentBuffer parameter contains the data just received.

    For the MQSendExit and the MQSecurityExit, 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 Client for Java to interpret.

  3. Bundle the given class in a Jar file, for example, mquserexits.jar.
  4. Place the Jar file in the WebLogic classpath. Edit the setDomainEnv.cmd file located in the WebLogic domain directory to append the Jar file name to the CLASSPATH. To do this, find the following code in the setDomainEnv.cmd file:
  5. set CLASSPATH=%ARDIR%\ant\ant.jar;%JAVA_HOME%\jre\lib\rt.jar

    and append the following line to it:

    ;%EXIT_DIR%\mquserexits.jar

    Before you append the code containing the Jar file name to the CLASSPATH, you can define the directory in which the Jar file resides, as follows:

    set EXIT_DIR=D:\UserExits

Previous Document Next Document