How to connect to a local MQseries queue using Python?

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

import pymqi

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

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

but I get an 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 a queue manager QM_APPLEwith a local network Q1.

What is wrong with my code?

+5
source share
2 answers

, , , . , , mqi , . , ? , , .

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)
+3

, , Python Java. Python , , . Java, , . IBM Java, JMS . :

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

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

: http://www.ibm.com/developerworks/websphere/techjournal/0610_woolf/0610_woolf.html

IBM API Java JMS WMQ : http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.csqzaw.doc/uj10120_.htm

, Python, , WMQ, , , , . , . Java JMS- , , . , " ": http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.csqzaw.doc/ja11010_.htm

- T.Rob

+2

All Articles