zpymqi
is a port of PyMQI from Zato to run natively on the z/OS platform. The z/OS version has been extended, to make PCF easier to use, and to add tracing capabilities to make it easier to debug the MQ flows.
If you have already installed PyMQI, refer to Getting Started with PyMQI on z/OS
This code has been developed and tested in the following environment:
Currently, you cannot use python pip
to install zpymqi
/u/colin/pymqi
)zpymqi.pax
into this directory using a file transfer tool (SFTP, SCP etc).pax -rf /u/colin/zpymqi.pax .
If you list this directory you should now see something like:
- -rwxr-xr-- 1 OMVSKERN SYS1 2302 Feb 11 15:53 CMQZC.py
- -rwxr-xr-- 1 OMVSKERN SYS1 6303 Feb 11 15:53 CMQXC.py
- -rwxr-xr-- 1 OMVSKERN SYS1 53843 Feb 11 15:53 CMQCFC.py
- -rwxr-xr-- 1 OMVSKERN SYS1 63317 Feb 11 15:53 CMQC.py
- -rwxr-xr-- 1 OMVSKERN SYS1 4022 Mar 15 17:00 MQOTHER.py
- -rwxr-xr-- 1 OMVSKERN SYS1 150352 May 16 13:05 __init__.py
- -rwxr-xr-- 1 OMVSKERN SYS1 14824 May 17 17:20 PCF.py
- -rwxr-xr-- 1 OMVSKERN SYS1 1466368 May 22 15:15 zpymqe.so
You need to set up environment variable PYTHONPATH to point to the code. You also need to set up STEPLIB.
For example, in your .profile
shell script:
# set up Python path
export PATH=/usr/lpp/IBM/cyp/v3r8/pyz/bin:$PATH
# set up MQ Libraries
export STEPLIB=MQM.V900.SCSQANLE:MQM.V900.SCSQANLE:MQM.V900.SCSQAUTH:$STEPLIB
# set up PYTHONPATH to point to where the PyMQI directory is
export PYTHONPATH=/u/colin/:$PYTHONPATH
Without this you will get exceptions like:
ImportError: cannot import name 'zpymqe' from partially initialized module 'pymqi'
There is Python code to most of the work, and there is a load module object (zpymqi) for issuing the MQ API requests.
Create file ivp.py
import pymqi
from pymqi import CMQC, CMQCFC
# replace with your Queue Manager name
qmgr = pymqi.connect('CSQ9')
qmgr.disconnect()
and execute it
python3 ivp.py
If the script raises no exceptions, you have succesfully connected to your queue manager using PyMQI and verified your installation.
The zpymqi code is written in C, and compiled as ASCII. When PyMQI calls the zpymqi code, the values are passed across in ASCII.
The pymqi/__init__.py
code translates the ASCII code to EBCDIC, where possible. It is possible that applications may have to translate data themselves, or set the appropriate options for MQ to do the translation.
If you hit this problem, please let the author know so the code can be updated.
Python on z/OS has some interesting quirks. I’ve documented some of them here.
This code was based on PyMQI from Zato, and the work by Darusz Suchojad. Without him (and others) there would be no PyMQI code.