A Fast Way to Get Started with Websphere MQ for DB2 Active-Active Databases

A few months ago, IBM made two-site Q Replication available in DB2 Advanced ESE and InfoSphere Warehouse at no additional cost. The main reason was to give DB2 a built-in solution for active-active databases. Since a lot of DB2 people are new to Q Replication, I will show you how easy it is to set up a real-world configuration and give it a try.


To help you refer to the information in the future, I'm dividing this topic into two posts - one for fast set up of WebSphere MQ (this post) and one for the Q Replication set up that takes advantage of the MQ set up (an upcoming post). Neither post will be very long and you'll probably spend no more than 15-20 minutes with each.

The instructions in these posts are for two databases on a single Windows system. You can modify the instructions to work for two different systems or for UNIX/Linux systems with just a few changes (provided at the end of this post).


Before You Start


First, you'll need a copy of MQ V7. If you don't have one, you can download it from one of two places - IBM's Passport Advantage or the MQ pages on You should be able to download from Passport Advantage if you've purchased DB2 or InfoSphere Warehouse. That's because most DB2 and InfoSphere Warehouse editions include a copy of MQ. Otherwise, if you're just kicking the tires, you can download an evaluation copy of MQ from the WebSphere MQ pages on


Next, you'll need a copy of a DB2 product at version 9.7 FP4 or above for a new DB2 command that helps you setup MQ quickly and easily. If you have a DB2 server and it's at a level earlier than 9.7 FP4, you can upgrade your DB2 to the latest fix pack. If you cannot upgrade your DB2 server at this time, you can download the IBM Data Server Client and install the latest release of the Client from's DB2 pages without affecting your DB2 server.


Do It Yourself


Let's get started! You will now set up Websphere MQ for active-active Q Replication between two databases called SITE1 and SITE2. At a high level, your MQ configuration will look like the following:



1) Bring up a DB2 Command window, create a temporary directory called myscripts under say C:, and switch to it:


mkdir c:\myscripts
cd \myscripts


If you are running Windows 7, make sure to run the DB2 command window as Administrator. Otherwise, you will get an authorization error in a later step.


2) Copy and paste the commands below (explained later) into a new file called activemq.asnclp in C:\myscripts:


asnclp session set to q replication;
create mq script config type B
mqserver 1 name site1 mqhost "" mqport "2414",
mqserver 2 name site2 mqhost "" mqport "2415";


3) Change "" to the host name or IP address of your system (or 'localhost' if you prefer) and save the file.
4) Issue the following command from your DB2 Command window:


asnclp -f activemq.asnclp


5) From your DB2 command window, run the two batch files that were generated by the asnclp command*:




You should now have two running queue managers, one named SITE1 and one named SITE2, along with all the objects needed for them to send messages to each other.


6) You can verify that your queue managers are running by issuing the following command:




The output from this command should read as follows:




7) You can verify the queues are correct using the DB2 Replication Center.


My next post will show you how you can use a command to verify that your MQ configuration is correct for Q Replication. In the mean time, you can use a user interface called the Replication Center. This requires you create a few tables for Q Replication and add some Q Replication definitions to them, but you do not have to run Q Replication just to verify queues. See how to do it in the ChannelDB2 video titled Verifying MQ for Q Replication.


That's it! You completed the MQ set up!


What's in the File called activemq.asnclp ?


The most important statement in this file is the asnclp Create MQ Script statement. The things you should know about it are the following:


  • The recommended name for your MQ server (queue manager) is the same as the database name it will be used with.
    • In my posts, I am using SITE1 and SITE2 as the database names.
    • This convention is not required. It is a best practice.


  • The command needs the host name or IP address for the system where each queue manager will be created.
    • In my posts, it is "" for both queue managers because I am running both on one system.
    • Note that a best practice is to have each queue manager colocated with the DB2 server it is used with.


  • Each queue manager needs a TCP/IP port where it receives messages from the other queue manager.
    • Two port numbers are needed to differentiate the two MQ servers on the same system.
    • For this exercise, those are "2414" and "2415".


Understanding How to Use the Batch Files and Shell Scripts


The asnclp command uses the information in activemq.asnclp to create four files - two batch files for Windows (used in this post) and two shell scripts for UNIX/Linux. Each can create one queue manager and all necessary MQ objects (queues, channels, listener) for that queue manager. The name of the queue manager is included in the file name.


If you run on UNIX/Linux systems, use the generated shell scripts instead of the batch files. For this example, run the and files.


You'll eventually want to learn more about the MQ objects and MQ commands after you finish working with this post. For example, what's a channel or how do I stop and restart queue managers :) The MQ Information Center is an excellent resource for this. That's were the tutorial and Flash overview are. It also contains reference information about queue manager commands and MQ scripting commands.


Running with Two Separate Systems


At a high level, your MQ configuration will look like the following if you have two systems:



When you are ready to implement this configuration, you can use the instructions here with just a couple of changes as follows:


  • Update the file called activemq.asnclp.
    • Have the first mqhost parameter of the Create MQ script command be one of the host names or IP addresses and the second mqhost parameter be the other.
  • Run each of the two generated batch files or shell scripts on the appropriate system.
    • In other words, run the site1 script on one system and the site2 script on the other.


*In step 5, you may see a syntax error that starts with message number AMQ8405 for one command. This can be ignored. It causes no problem. 


In step 5, if you are running Windows 7 and you are not running as Administrator, you will get an authorization error that starts with message number AMQ7077.  To resolve this error, you need to run the DB2 command windows as Administrator.


Views: 4027


You need to be a member of ChannelDB2 to add comments!

Join ChannelDB2

Featured Downloads

Try BLU Acceleration on Cloud

© 2018   Created by channeldb2.   Powered by

Badges  |  Report an Issue  |  Terms of Service