0

I'm trying to connect with a remote MQ queue/serie and I only have a .bindings file to do it. I'm trying the python library "pymqi" but I can't connect using binding mode. Does someone knows what should I do or where should I place the file in order to use it with the library? Is there some other python solution to connect to the MQ queue?

this is a glimpse of my .bindings file:

JMSC/ClassName=com.ibm.mq.jms.MQQueueConnectionFactory
JMSC/FactoryName=com.ibm.mq.jms.MQQueueConnectionFactoryFactory
JMSC/RefAddr/0/Type=VER
JMSC/RefAddr/0/Encoding=String
JMSC/RefAddr/0/Content=7
JMSC/RefAddr/1/Type=TRAN
JMSC/RefAddr/1/Encoding=String
JMSC/RefAddr/1/Content=1
JMSC/RefAddr/2/Type=QMGR
JMSC/RefAddr/2/Encoding=String
JMSC/RefAddr/2/Content=MQFEND00
JMSC/RefAddr/3/Type=HOST
JMSC/RefAddr/3/Encoding=String
JMSC/RefAddr/3/Content=somehost
JMSC/RefAddr/4/Type=PORT
JMSC/RefAddr/4/Encoding=String
JMSC/RefAddr/4/Content=1414
JMSC/RefAddr/5/Type=CHAN
JMSC/RefAddr/5/Encoding=String
JMSC/RefAddr/5/Content=PORTALS.MQFEND00

It has like 100 params, that are the first 6,

Thanks

update 22/05/2019:

I will add more information about what I try. I tried to connect with bindings mode as I saw on the pymqi documentation:

qmgr = pymqi.connect('MQFEND00')

And I get this error:

MQI Error. Comp: 2, Reason 2058: FAILED: MQRC_Q_MGR_NAME_ERROR

I'm not sure if it's the queue_manager, someone knows how can I get the queue_manager from bindings file?

I've also tried to connect with host, channel and port:

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

And I get an error of not authorized, I think it's because this second way is to connect with the client and I would need user and password which I haven't.

JoshMc
  • 10,239
  • 2
  • 19
  • 38
GuillemOF
  • 1
  • 2
  • Do you get an error message ? Please post it here. – Axel Podehl May 22 '19 at 06:58
  • Hi Axel, I get this error message: MQI Error. Comp: 2, Reason 2058: FAILED: MQRC_Q_MGR_NAME_ERROR. I placed the bindings file in the same route as my code and try to connect with this command: qmgr = pymqi.connect('MQFEND00') – GuillemOF May 22 '19 at 07:27
  • I would like to connect with the bindings file. I can't connect with the client mode because I just need to consume the queues but I haven't got control of it – GuillemOF May 22 '19 at 07:31
  • Does your python application run on the same server as the queue manager? – JoshMc May 22 '19 at 10:25
  • What is the value of `TRAN` in you binding file? – JoshMc May 22 '19 at 10:27
  • The value of TRAN is 1 as you can see on the example, I'm connecting to a VPN where should have to be the queues – GuillemOF May 22 '19 at 10:31
  • Binding mode as referenced by pymqi means you run on the same server. A JMS/XMS .bindings file is different than binding mode. pymqi would not support a .bindings file, you need to pull the details and connect directly like you attempted. The mq admin will need to look at the queue manager logs to tell you the cause of the 2035. – JoshMc May 22 '19 at 10:47
  • Hi Josh first of all thanks for your answer I really appreciate this. There isn't anyway to connect with my remote queues using python with my jms bindings file? – GuillemOF May 22 '19 at 11:14
  • I was talking about pymqi. You could try pyjms and interface with the ibm mq jms jar files. Likely would not fix your 2035 error. – JoshMc May 22 '19 at 12:48
  • You said "to connect with the client and I would need user and password which I haven't." - without username and password you won't get far... If your remote MQ server is running and you use pymqi your python code should be able to make the connection. The authorization error is good first step, but you should get that username and password. – Axel Podehl May 22 '19 at 13:30

2 Answers2

0

If you want to use binding mode, you should setup pymqi with server or binding parameters. You can not use binding and client mode simultaneously:

#From pymqi folder    
cd ./code
./setup.py build server

I am not sure, that you can use .bindings file with pymqi without parsing it himself.

Seyf
  • 305
  • 2
  • 10
0

Probably I'm very late to this discussion, but:

import pymqi


queue_manager = 'MQFEND00'
channel = 'PORTALS.MQFEND00'
host = 'somehost'
port = '1414'
conn_info = '%s(%s)' % (host, port)
qmgr = pymqi.connect(queue_manager, channel, conn_info)
# other operations, see https://dsuch.github.io/pymqi/examples.html for more.
qmgr.disconnect()

You must have a MQ Client installed in the same machine that you run pymqi; Are you using conn_info like the code snnipet?