views:

476

answers:

3

I am new to mqseries and I started with IBM WebSphere MQ curses. There are examples with MQ_APPLE and MQ_ORANGE queue managers. I have no problem with sending messages to local or remote queue with MQ Explorer, but I wanted to send such message from code: Python or Java. I tried Python pymqi library with code like this:

import pymqi

qmgr = pymqi.QueueManager(None)
qmgr.connect('QM_APPLE')

putq = pymqi.Queue(qmgr, 'Q1')
putq.put('Hello from Python!')

but I receive error:

Traceback (most recent call last):
    File "mq_put.py", line 4, in <module>
        qmgr.connect('QM_APPLE')
    File "c:\Python26\lib\site-packages\pymqi.py", line 758, in connect
        raise MQMIError(rv[1], rv[2])
pymqi.MQMIError: MQI Error. Comp: 2, Reason 2540: FAILED: MQRC_UNKNOWN_CHANNEL_NAME

There is QM_APPLE queue manager with Q1 local queue.

What is wrong with my code?

+1  A: 

Based on the error it appears that you are attempting to connect to a remote queue manager, but you are using the local queue manager bindings method to connect. I say this because the error is stating that the mqi client doesn't know which channel to connect to. Can you please clarify if you are using a local queue manager or a remote queue manager? I have pasted the code below to connect to a remote queue manager using a channel.

import pymqi

queue_manager = "QUEUE_MANAGER_NAME"
channel = "SVRCONN.1"
host = "host.domain.com"
port = "1434"
conn_info = "%s(%s)" % (host, port)

qmgr = pymqi.QueueManager(None)
qmgr.connectTCPClient(queue_manager, pymqi.cd(), channel, conn_info)
gwhitake
I want to use local queue. AFAIK there is no channel. Channel appears on lesson about sending message in client-server configuration (I have problems with this lesson too). I completed lesson about sending messages using local and remote queues and wanted to do it from code.
Michał Niklas
As T.Rob said, it appears you are using a pymqi module that is built in client mode. If you want to use a bindings connection (local queue manager, no channel) you need to use a pymqi module built in server mode. Check out this link: http://packages.python.org/pymqi/index.html#download-build-installOtherwise, you can always just create a channel on your local queue manager and use the connectTCPClient method like above.
gwhitake
I created channel of `receiver` type, but I cannot activate it. What type of channel should I create?
Michał Niklas
I created channel of `connection with server` type, and was able to send message to it! Thank you.
Michał Niklas
+1  A: 

Your post mentions you'd like this to run in Python or Java. Python I can't help with but the previous responder did, so cool. As far as Java, maybe I can point you in the right direction. IBM supports both Java and JMS and provides a number of sample programs of each. By default, these are installed at:

C:\Program Files\IBM\WebSphere MQ\tools\wmqjava

C:\Program Files\IBM\WebSphere MQ\tools\jms

I also offer up my own sample code here: http://www.ibm.com/developerworks/websphere/techjournal/0610_woolf/0610_woolf.html

The documentation for the IBM's implementation of the Java and JMS WMQ API is here: http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.csqzaw.doc/uj10120_.htm

The docs I found on the Python module appear to indicate that it must be linked to the Client or Server WMQ libraries and your error seems to indicate that you have the client bindings linked. If that's the case, you must provide the connection info as the previous posted pointed out. The Java and JMS code support either connection type so there's no linking to be done but you still must supply the proper connection details. In particular, please read the chapter on Connection Differences: http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.csqzaw.doc/ja11010_.htm

-- T.Rob

T.Rob
You are right. I used client bindings while only such type of module is available in precompiled form. In samples I have found `MQSample.java` and it seems to work. Thank you.
Michał Niklas
+1  A: 

You are right. I used client bindings while only such type of module is available in precompiled form.

Hello Michał,

I don't follow StackOverflow that closely and have only now seen your question. As you can see, PyMQI is by default built in MQ client as that's what 90% of users need but if there's a need for providing Windows binaries built in the bindings mode then I'll be happy to create it for you. Can you please open a bug report regarding it on Launchpad? https://launchpad.net/pymqi

Cheers!

Dariusz Suchojad
Hello, nice to see you on SO. OK, I will open such report.
Michał Niklas