Posted by: Rich Cumbers | March 13, 2009

Getting MQ and DB2 to talk on windows

Something had to force me from the blogging wilderness that I have been in since August of 2008. I’ll freely admit that I have neglected this blog, and intend to change. No really I do. It is not that I have not done anything interesting since August, since my last post we have released WebSphere MQ File Transfer Edition 7.0 and are now planning and developing for the future releases. My lack of posting has not been down to lack of time. In the time that it takes to complete a mission on Far Cry 2 (xbox360 naturally), or watch an episode of 24 (fantastic 7th season) I could have posted 2 or 3 articles. I think it comes down to not really finding my blogging voice, when reading my posts back to myself I always cringe and I think this is something I am just going to have to get used to. I think the term “strap on a pair” would best describe what I need to do.

Anyway on to my post. My current day job involved setting up a WebSphere MQ V7 Queue Manager to use DB2 as a Resource Manager for XA transactions. There are some docs on the infocenter for WMQ V7 here and here, but in following these I did not manage to get my queue manager talking and playing nice with a DB2 instance. There is also a rather well written DeveloperWorks article by Mr Ben Ritchie that has only one drawback and that is following the instructions for Windows does not make it all work nicely. So I thought I would explain my setup, and what I had to do to get it to work.

I have a Windows machine that has both WebSphere MQ V7 and DB2 9.5 installed. I want to use WebSphereMQ as the coordinator for my XA transactions. Nothing fancy, just a simple XA connections. The first thing to do is to create the queue manager that you are going to use. For the purposes of this article I shall call my queue manager DATABASE_QM. I also have a database called XADATABASE. My windows userid is fred and my password is pass1234.

The first thing the docs do not tell you is that you need to copy/move a file called jdbcdb2.dll from <WMQ Install Dir>/java/lib/jdbc/jdbcdb2.dll to <WMQ Install Dir>/exits. If you do not do this setup, then in the AMQERR**.log you will find errors telling you that MQ cannot find the jdbcdb2.dll file. A simple copy/move action and you are ready to move to the next step

All the configuration for the connection occurs in the database. Well everything except a single command. The configuration of the queue manager in Windows is best done using MQ Explorer. Access the queue manager properties by right clicking on the queue manager and selecting properties. Navigate to the “XA resource managers” menu option. Here is where you will add the details of the connection to the DB2 database. Click Add, and you will be presented with a dialog box. Here is where you Name your Resource Manager (anything you like), give it the name of the Switch File to use (jdbcdb2.dll), the XAOpenString which will consist of the following db=XADATABASE, userid=fred, pwd=pass1234, toc=p, tpm=mq; substitute your values for db, userid and pwd. Leave XACloseString blank, I won’t lie I have no idea what I would use this for, I just want to get MQ and DB2 talking! Finally ThreadOfControl is set to Process, which is good enough for me.

I mentioned the command to run on DB2, run the following:ย db2 UPDATE DBM CFG USING TP_MON_NAME MQ

Now aside from the action to move/copy jdbcdb2.dll to the exits folder you have followed what all the docs say you should do. The next step would be to stop the queue manager (if you have it running), and then start the queue manager. Except that does not work. You will get an error telling you that the queue manager could not connect to the Resource Manager. So here is the bit you really must do. The user id for which the default name is MUSR_MQADMIN that the ‘MQ Services’ process ‘amqmsrvn.exe’ is running as needs to belong to the group DB2USERS. The information about this can be found here. Once you add the user to the group, stop/start the MQ Services process, restart your queue manager and you should not have any error messages in your log files. At least it worked for me!

And so ends my self imposed blogging exile. Hope to post again soon, rather then 7 months down the line!



  1. Hi,
    Thank you for posting this. I was just trying to do what you have done, and didn’t know about MUSR_MQADMIN being part of DB2USERS group.

    So now it’s working ๐Ÿ™‚

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


%d bloggers like this: