+

Search Tips | Advanced Search

Scenario: Dynamically routing client connection requests

In this scenario, we can dynamically route client connection requests to a target server, based on the name of the channel being used.


Before you begin


About this task

If we use the name of the queue manager as the first part of the channel name, MQIPT need use only one route to service all connection requests. For example, to connect to QM1, the name of a SVRCONN channel might be QM1.MQIPT.CHANNEL.

The list of queue manager and server names to be used is read from a configuration file. The name and location of the configuration file, called SampleOneRouteExit.conf, is defined with the MQIPT SecurityExitName and SecurityExitPath properties.

Figure 1. Dynamic one route exit network diagram

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 dynamically route client connection requests, complete the following steps:

  1. Create three different queue managers on three separate servers. Each queue manager has a SVRCONN channel named after itself, for example, QM1.MQIPT.CHANNEL on queue manager QM1, and an empty local queue named MQIPT.LOCAL.QUEUE.
  2. On MQIPT1:
    1. In the mqipt_path\exits subdirectory (where mqipt_path is the location where MQIPT is installed), create a sample configuration file, called SampleRoutingExit.conf that contains the names of your three queue managers:
      QM1   server1.company2.com:1414
      QM2   server2.company2.com:1415
      QM3   server3.company2.com:1416
      Ensure 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.

      You must change these server names to match your environment. Note that all queue manager names in the list must be unique. If you list the same name more than once, even if the queue managers are on different servers, only the last entry for that name is registered.

    2. Open a command prompt and enter the following commands:
      C:
      cd \mqipt\exits
      javac -classpath C:\mqipt\lib\com.ibm.mq.ipt.jar;. SampleOneRouteExit.java
    3. Edit mqipt.conf and add a route definition:
      [route]
      ListenerPort=1415
      Destination=server1.company2.com
      DestinationPort=1414
      SecurityExit=true
      SecurityExitName=SampleOneRouteExit
    4. Open a command prompt and start MQIPT:
      C:\mqipt\bin\mqipt C:\mqiptHome
      where 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:\mqipt\exits\SampleOneRouteExit
      MQCPI080 ......and timeout of 5 seconds
      MQCPI078 Route 1415 ready for connection requests
  3. At a command prompt on the IBM MQ client, enter the following commands:
    1. Set the MQSERVER environment variable:
      SET MQSERVER=QM1.MQIPT.CHANNEL/TCP/10.9.1.2(1415)
    2. Put a message:
      amqsputc MQIPT.LOCAL.QUEUE QM1
      Hello world 1
      Press Enter twice after typing the message string.
    3. Get the message:
      amqsgetc MQIPT.LOCAL.QUEUE QM1
      The message, Hello world 1 is returned.
    4. Reset the MQSERVER environment variable:
      SET MQSERVER=QM2.MQIPT.CHANNEL/TCP/10.9.1.2(1415)
    5. Put a message:
      amqsputc MQIPT.LOCAL.QUEUE QM2
      Hello world 2
      Press Enter twice after typing the message string.
    6. Get the message:
      amqsgetc MQIPT.LOCAL.QUEUE QM2
      The message, Hello world 2 is returned.
    7. Reset the MQSERVER environment variable again:
      SET MQSERVER=QM3.MQIPT.CHANNEL/TCP/10.9.1.2(1415)
    8. Put a message:
      amqsputc MQIPT.LOCAL.QUEUE QM3
      Hello world 3
      Press Enter twice after typing the message string.
    9. Get the message:
      amqsgetc MQIPT.LOCAL.QUEUE QM3
      The message, Hello world 3 is returned.