0

I am newbie to python. I am trying to connect to my IBM MQ and put some messages in them through the Python code.

import pymqi

queue_manager = 'XXXXXX'
channel = 'XXXXX'
host = 'XXXXX'
port = 'XXXX'
conn_info = '%s(%s)' % (host, port)
qmgr = pymqi.connect(queue_manager, channel, conn_info)
file = open('E:\D Drive Back up\Scripts\Data1.csv','r')
y = file.readlines()
print y[1]
putQ = pymqi.Queue(qmgr, queue_manager)
putQ.put(y[1])
qmgr.disconnect()

Sample Data which I am trying to input:

{1:F01COBADEFFGXXX3575743055}{2:I103BARCGB22GXXXU3003}{4:##:20:Forw092010004R1##:23B:CRED##:32A:181010EUR250000,00##:50F:/N101000004EUR##1/John Doe##2/Dankelmannstrasse 6##3/DE/Berlin##:59F:/N101000004EUR##1/Jane Doe##2/Wissmannstr 1##3/DE/Berlin##:71A:BEN##-}{5:{MAC:11111111}{CHK:6E470F24FDE6}}

The output I am getting is this:

E:\D Drive Back up\Scripts>python MQ.py
{1:F01COBADEFFGXXX3575743055}{2:I103BARCGB22GXXXU3003}{4:##:20:Forw092010R1##:23B:CRED##:32A:181010EUR1000000,00##:50F:/N101000004EUR##1/John Doe##2/Dankelmannstrasse 6##3/DE/Berlin##:59F:/N101000004EUR##1/Jane Doe##2/Wissmannstr 1##3/DE/Berlin##:71A:BEN##-}{5:{MAC:11111111}{CHK:6E470F24FDE6}}

Traceback (most recent call last):
File "MQ.py", line 19, in 
putQ.put(y[1])
File "C:\Users\aassharma\AppData\Local\Continuum\anaconda2\lib\site-packages\pymqi_init_.py", line 1727, in put
self._realOpen()
File "C:\Users\aassharma\AppData\Local\Continuum\anaconda2\lib\site-packages\pymqi_init.py", line 1632, in __realOpen
raise MQMIError(rv[-2], rv[-1])
pymqi.MQMIError: MQI Error. Comp: 2, Reason 2085: FAILED: MQRC_UNKNOWN_OBJECT_NAME
JoshMc
  • 10,239
  • 2
  • 19
  • 38
  • I don't see your queue name anywhere in your code snippet, can you update your question to show the line where you set the queue name? – Morag Hughson Jul 03 '19 at 09:21
  • You are attempting to put to a queue called what you have queue_manager set to. Instead specify the name of a queue in your `pymqi.Queue` call. – JoshMc Jul 03 '19 at 10:56

1 Answers1

2

Compare your code to the pymqi put sample from - https://dsuch.github.io/pymqi/examples.html#how-to-put-the-message-on-a-queue

import pymqi

queue_manager = 'QM1'
channel = 'DEV.APP.SVRCONN'
host = '127.0.0.1'
port = '1414'
queue_name = 'TEST.1'
message = 'Hello from Python!'
conn_info = '%s(%s)' % (host, port)

qmgr = pymqi.connect(queue_manager, channel, conn_info)

queue = pymqi.Queue(qmgr, queue_name)
queue.put(message)
queue.close()

qmgr.disconnect()

As Morag Hughson and JoshMc already pointed out, the difference is queue_name. You don't specify one.

It should be something like 'DEV.QUEUE.1' and used as the second parameter in the call to connect to the queue - queue = pymqi.Queue(qmgr, queue_name). You pass in the Queue Manager, which I guess will be something like 'QM1', which is very unlikely to be the queue name on your MQ Server, and also why you are getting the error MQRC_UNKNOWN_OBJECT_NAME.

chughts
  • 4,210
  • 2
  • 14
  • 27