Assigning a channel exit in IBM MQ classes for Java

We can assign a channel exit using IBM MQ classes for Java.

There is no direct equivalent to the IBM MQ channel in IBM MQ classes for Java. Channel exits are assigned to an MQQueueManager. For example, having defined a class that implements the WMQSecurityExit interface, an application can use the security exit in one of four ways:

  • By assigning an instance of the class to the MQEnvironment.channelSecurityExit field before creating an MQQueueManager object
  • By setting the MQEnvironment.channelSecurityExit field to a string representing the security exit class before creating an MQQueueManager object
  • By creating a key/value pair in the properties hashtable passed to MQQueueManager with a key of CMQC.SECURITY_EXIT_PROPERTY
  • Use a client channel definition table (CCDT)

Any exit assigned by setting the MQEnvironment.channelSecurityExit field to a string, creating a key/value pair in the properties hashtable, or using a CCDT, must be written with a default constructor. An exit assigned as an instance of a class does not need a default constructor, depending on the application.

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, using MQEnvironment:
 MyMQExits myexits = new MyMQExits();
 MQEnvironment.channelSecurityExit = myexits;
 MQEnvironment.channelSendExit = myexits;
 MQEnvironment.channelReceiveExit = myexits;
 :
 MQQueueManager jupiter = new MQQueueManager("JUPITER");
If more than one method is used to assign a channel exit, the order of precedence is as follows:
  1. If the URL of a CCDT is passed to the MQQueueManager, the contents of the CCDT determine the channel exits to be used and any exit definitions in MQEnvironment or the properties hashtable are ignored.
  2. If no CCDT URL is passed, exit definitions from MQEnvironment and the hashtable are merged

    • If the same exit type is defined in both MQEnvironment and the hashtable, the definition in the hashtable is used.
    • If equivalent old and new types of exit are specified (for example the sendExit field, which can only be used for the type of exit used in versions of IBM MQ earlier than Version 7.0, and the channelSendExit field, which can be used for any send exit), the new exit (channelSendExit) is used rather than the old exit.

If we have declared a channel exit as a string, we must enable IBM MQ to locate the channel exit program. We can do so in various ways, depending on the environment in which the application is running and on how the channel exit programs are packaged.

  • For an application that is running in an application server, we must store the files in the directory shown in Table 1 or packaged in JAR files referenced by exitClasspath.
  • For an application that is not running in an application server, the following rules apply:

    • If your channel exit classes are packaged in separate JAR files, these JAR files must be included in the exitClasspath.
    • If your channel exit classes are not packaged in JAR files, the class files can be stored in the directory shown in Table 1 or in any directory in the JVM system class path or exitClasspath.

The exitClasspath property can be specified in four ways. In order of priority, these ways are as follows:

  1. The system property com.ibm.mq.exitClasspath (defined on the command line using the -D option)
  2. The exitPath stanza of the mqclient.ini file
  3. A hashtable entry with the key CMQC.EXIT_CLASSPATH_PROPERTY
  4. The MQEnvironment variable exitClasspath

Separate multiple paths using the java.io.File.pathSeparator character.

Platform Directory

AIX

Linux

/var/mqm/exits (32-bit channel exit programs)

/var/mqm/exits64 (64-bit channel exit programs)

Windows install_data_dir\exits
Note: install_data_dir is the directory that you chose for the IBM MQ data files during installation. The default directory is C:\ProgramData\IBM\MQ. Parent topic: Use channel exits in IBM MQ classes for Java