Using Exit Implementation

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

To implement an exit, you 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

In order 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.MQSecurityExit 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 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.

    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 Client for Java to interpret.

  3. Bundle the given class in a Jar file, for example, mquserexits.jar.
  4. Place the Jar in the WebLogic classpath, by editing the setDomainEnv.cmd file, which is present in the WebLogic domain directory. To do this, locate the following line 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