, by using DB2's
, or by
coordinating the commit of transactions
to DB2 and MQ. However, I find that a lot of DB2 people are hesitant to try these features because they're unfamiliar with MQ. That really shouldn't stop them :) Especially now. Starting with 9.7 FP4, DB2 has a new command (actually, much improved command) that makes it very easy to set up MQ for use with DB2.
is geared towards use with Q Replication, but the MQ objects it creates could be used with any function combining DB2 and MQ.
Before You Start
Do It Yourself
<1. Bring up a DB2 command window, create a directory called myscripts under, say, C:, and switch to it:
<2. Copy and paste the following text (explained later) into a file named mq.asnclp in c:\myscripts:
asnclp session set to q replication;
create mq script
config type u
mqserver 1 name sample mqhost "spongebob.svl.ibm.com" mqport "2404",
mqserver 2 name cognos mqhost "spongebob.svl.ibm.com" mqport "2405";
<3. Change "spongebob.svl.ibm.com" 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:
<5. Run the following two batch files (explained later) that were generated by the asnclp command:
<6. You can verify your queue managers are running by issuing the following command:
7. You can verify the queues are correct using the DB2 Replication Center.
This requires you create a few tables for Q Replication, 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
. At some point, I'll have posts that show other ways to verify your MQ will work for DB2 needs.
What's in the File called mq.asnclp?
Like I said earlier, the asnclp
Create MQ Script command
is geared towards use with Q Replication but the resulting MQ objects can be used any way you want. For this exercise, though, the important things to know are the following:
- The recommended name for your MQ server (queue manager) is the same as the database it will be used with.
- In this example, I assume you will eventually have databases called Sample and Cognos.
- This is not required, just a recommendation.
- The command needs the host name or IP address for the system where each queue manager will be created.
- That's the first quoted string in each of the last two lines ("spongebob.svl.ibm.com").
- For this exercise, the DB2 servers and MQ servers must be colocated on the same system(s).
- Each queue manager needs a TCP/IP port where it receives messages from the other queue manager.
- That's the second quoted string in each of the last two lines ("2404" and "2405").
What's in the Batch Files and Shell Scripts?
The asnclp command uses the information in mq.asnclp to create four files - two batch files for Windows and two shell scripts for UNIX. Each file 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.
These batch files/scripts first create an MQ script file that define 6-7 MQ objects. They then run three MQ commands - one to create the queue manager, one to start the queue manager, and one to pass the MQ script to the queue manager.
You'll eventually want to learn more about these objects and MQ's 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
MQ scripting commands