On .NET and WebSphere MQ

I was doing a search on other blogs that talk about MQ today, and came across a post from a guy who has been having trouble with the .NET interface.

Here’s my “open letter”-style response to his problems…

Hi. I realise I’m 3 weeks late, but I just came across your blog.

I’m really sorry that you had so much difficulty with the .NET interface for WebSphere MQ. It sounds like it was pretty frustrating. All I can say is that it looks like there is some confusion about the different methods of connection.

First of all, you mention the amqsputc program, which is a C program that enables you to make a client mode connection to a queue manager. You then go on to describe the use of the amqsput program, which uses a bindings mode connection to attach to a queue manager (this only works where the program is running on the same host as the queue manager). By adding those additional parameters after the queue manager name (open options, close options, remote queue manager name) you will actually be asking a local queue manager to forward your message to a remote queue manager.

I agree that the 8208 value is not very helpful. If you look at the source code for amqsput (amqsput0.c in MQ_INSTALL_DIR\Tools\c\Samples) you’ll find that it corresponds to 2 MQ Constants:

O_options = MQOO_OUTPUT  /* open queue for output     */
| MQOO_FAIL_IF_QUIESCING /* but not if MQM stopping  */
;                      /* = 0x2010 = 8208 decimal   */

In a .NET program, you’d specify the same constants, from the MQC object (this snippet is taken from the nmqsput.cs sample):

mqQueue = mqQMgr.AccessQueue( queueName, 
 MQC.MQOO_OUTPUT              // open queue for output
 + MQC.MQOO_FAIL_IF_QUIESCING );// but not if MQM stopping

I actually think that taken together, our documentation and samples for the .NET interface are reasonably good. There’s a section in the Using .NET book (provided as online help) which provides information on Connection differences between bindings and client connections, with example code fragments for each (actually my local copy of the help has the fragments for both, the copy on the website does not seem to currently). The AccessQueue method you mention is also fully documented.

I found that the MSMQ documentation and samples was far worse – plus the methods seem to change in each release, which meant that nine times out of ten it turned out that I was reading inaccurate information about how to use MSMQ.

Anyway, I’m glad you got going in the end. There’s a good independent MQ user site, MQSeries.net, which has forums where you can often find help for these kind of questions. We also have newsgroups.

Maybe this will be of use to others looking to use WebSphere MQ in a C# or .NET environment.

Leave a Reply