Scenario: Routing client connection requests to IBM MQ queue manager servers by using security exits
In this scenario, we can dynamically route client connection requests, in a round-robin fashion, to a group of three IBM MQ queue manager servers. The queue manager on each server in the group must be identical.
Before you begin
- Before you start to use this scenario, make sure that we have completed the prerequisite tasks listed in Scenarios: Getting started with MQIPT.
- Install Java 8.0 JDK.
- Add the Java bin subdirectory to the PATH environment variable.
About this task
The list of server names to be used is read from a configuration file. The name and location of the configuration file, called SampleRoutingExit.conf, is defined with the MQIPT SecurityExitName and SecurityExitPath properties.
The first time the amqsputc command is run, the IBM MQ message is placed on the MQIPT.LOCAL.QUEUE queue on the first server. The second time it is run, the message is placed on the queue on the second server, and so on. Using this setup, it is not possible for the amqsgetc command to retrieve the message just placed on the queue, because the client connection request used by the amqsgetc command is passed to the next queue in the list. But running the amqsputc command three times, followed by three amqsgetc commands, ensures that each message is retrieved in the same order.
Of course, by using another IBM MQ client, connecting directly to a queue manager (that is, not using the MQIPT in this sample), we can selectively retrieve messages from any of the queue managers.
This diagram shows the connection flow from the IBM MQ client (called client1.company1.com on port 1415) through MQIPT to three IBM MQ servers (called server1.company2.com, server2.company2.com, and server3.company2.com).
Procedure
To route client connection requests sequentially to three different IBM MQ queue manager servers by using security exits, complete the following steps:
- Create three identical queue managers named MQIPT.QM1 on three separate servers. Each queue manager has a SVRCONN channel named MQIPT.CONN.CHANNEL and an empty local queue named MQIPT.LOCAL.QUEUE.
- On MQIPT:
- In the C\mqiptHome\exits subdirectory (where C:\mqiptHome is the directory where the mqipt.conf file is located), create a sample configuration file, called SampleRoutingExit.conf that contains the names of your three queue managers:
where
server1.company2.com:1414 server2.company2.com:1415 server3.company2.com:1416Ensure that there are no blank lines before the first entry in the file and that each entry is a valid server name. If we have used different server names, change these names to match your environment.- Open a command prompt and enter the following command to copy the sample exit SampleRoutingExit.java to your MQIPT home directory:
copy C:\mqipt\exits\SampleRoutingExit.java C:\mqiptHome\exits\SampleRoutingExit.java- Enter the following commands to compile the sample exit:
C: cd \mqiptHome\exits javac -classpath C:\mqipt\lib\com.ibm.mq.ipt.jar;. SampleRoutingExit.java- Edit mqipt.conf and add a route definition:
[route] ListenerPort=1415 Destination=server1.company2.com DestinationPort=1414 SecurityExit=true SecurityExitPath=C:\mqiptHome\exits SecurityExitName=SampleRoutingExitNote: You do not necessarily have to set SecurityExitPath if you put SampleRoutingExit.conf in the default exits subdirectory as described in step 2b.- Start MQIPT. Open a command prompt and enter the following command:
C:\mqipt\bin\mqipt C:\mqiptHomewhere C:\mqiptHome indicates the location of the MQIPT configuration file, mqipt.conf. The following message indicates successful completion:5639-L92 (C) Copyright IBM Corp. 2000, 2017 All Rights Reserved MQCPI001 IBM MQ Internet Pass-Thru Version 2.1.0.0 starting MQCPI004 Reading configuration information from C:\mqiptHome\mqipt.conf MQCPI011 The path C:\mqiptHome\logs will be used to store the log files MQCPI006 Route 1415 has started and will forward messages to : MQCPI034 ....server1.company2.com(1414) MQCPI035 ....using MQ protocols MQCPI079 ....using security exit C:\mqiptHome\exits\SampleRoutingExit MQCPI080 ......and timeout of 5 seconds MQCPI078 Route 1415 ready for connection requests- At a command prompt on the IBM MQ client, enter the following commands:
- Set the MQSERVER environment variable:
SET MQSERVER=MQIPT.CONN.CHANNEL/TCP/10.9.1.2(1415)- Put three messages:
amqsputc MQIPT.LOCAL.QUEUE MQIPT.QM1 Hello world 1 amqsputc MQIPT.LOCAL.QUEUE MQIPT.QM1 Hello world 2 amqsputc MQIPT.LOCAL.QUEUE MQIPT.QM1 Hello world 3Press Enter twice after typing each message string.- Get the messages:
amqsgetc MQIPT.LOCAL.QUEUE MQIPT.QM1 amqsgetc MQIPT.LOCAL.QUEUE MQIPT.QM1 amqsgetc MQIPT.LOCAL.QUEUE MQIPT.QM1The messages, Hello world 1, Hello world 2, and Hello world 3 are returned.