-
we need install mqsdk and mqclient before install pymqi
sudo apt install ./ibmmq-sdk_9.1.5.0_amd64.deb
sudo apt install ./ibmmq-client_9.1.5.0_amd64.deb
pip install pymqi
export LD_LIBRARY_PATH=/opt/mqm/lib64:$LD_LIBRARY_PATH -
create qmgr, channel and LISTENER on MQ server
https://www.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.ins.doc/q009310_.htm
https://dsuch.github.io/pymqi/examples.html
create a user ID on the server that is not in the mqm group.
useradd testid
passwd testid
su – mqmmqm@ubunu2004:~$ crtmqm QUEUE.MANAGER.1 mqm@ubunu2004:~$ strmqm QUEUE.MANAGER.1 mqm@ubunu2004:~$ runmqsc QUEUE.MANAGER.1 5724-H72 (C) Copyright IBM Corp. 1994, 2020. Starting MQSC for queue manager QUEUE.MANAGER.1. AMQ8521I: Command completion and history unavailable. DEFINE QLOCAL (QUEUE1) 1 : DEFINE QLOCAL (QUEUE1) AMQ8006I: IBM MQ queue created. SET AUTHREC PROFILE(QUEUE1) OBJTYPE(QUEUE) PRINCIPAL('testid') AUTHADD(PUT,GET) 2 : SET AUTHREC PROFILE(QUEUE1) OBJTYPE(QUEUE) PRINCIPAL('testid') AUTHADD(PUT,GET) AMQ8862I: IBM MQ authority record set. SET AUTHREC OBJTYPE(QMGR) PRINCIPAL('testid') AUTHADD(CONNECT) 3 : SET AUTHREC OBJTYPE(QMGR) PRINCIPAL('testid') AUTHADD(CONNECT) AMQ8862I: IBM MQ authority record set. DEFINE CHANNEL (CHANNEL1) CHLTYPE (SVRCONN) TRPTYPE (TCP) 4 : DEFINE CHANNEL (CHANNEL1) CHLTYPE (SVRCONN) TRPTYPE (TCP) AMQ8014I: IBM MQ channel created. SET CHLAUTH(CHANNEL1) TYPE(ADDRESSMAP) ADDRESS('192.168.0.43') MCAUSER('testid') 5 : SET CHLAUTH(CHANNEL1) TYPE(ADDRESSMAP) ADDRESS('192.168.0.43') MCAUSER('testid') AMQ8877I: IBM MQ channel authentication record set. DEFINE LISTENER (LISTENER1) TRPTYPE (TCP) CONTROL (QMGR) PORT (1415) 6 : DEFINE LISTENER (LISTENER1) TRPTYPE (TCP) CONTROL (QMGR) PORT (1415) AMQ8626I: IBM MQ listener created. START LISTENER (LISTENER1) 7 : START LISTENER (LISTENER1) AMQ8021I: Request to start IBM MQ listener accepted.
-
test_mq.py
import pymqi queue_manager = "QUEUE.MANAGER.1" channel = "CHANNEL1" host = "192.168.0.43" port = "1415" queue_name = 'QUEUE1' message = 'Hello from Python!' conn_info = "%s(%s)" % (host, port) user = 'testid' password = 'password' qmgr = pymqi.connect(queue_manager, channel, conn_info, user, password) queue = pymqi.Queue(qmgr, queue_name) queue.put(message) queue.close() qmgr.disconnect()
(base) ubuntu@ubunu2004:~$ python test_mq.py
then you can verify it with amqsget:mqm@ubunu2004:/opt/mqm/samp/bin$ ./amqsget QUEUE1 QUEUE.MANAGER.1 Sample AMQSGET0 start message <Hello from Python!> no more messages Sample AMQSGET0 end
install IBM MQ 9.1 on Ubuntu
- download IBM_MQ_9.1.5_UBUNTU_X86-64.tar.gz from IBM site and unzip it to /tmp
- create mqm user and group on Ubuntu:
root@ubunu2004:/usr/lib# useradd mqm -m -s /bin/bash
root@ubunu2004:/usr/lib# id mqm
uid=1001(mqm) gid=1001(mqm) groups=1001(mqm) - create filesystem/dir for MQ
mkdir /var/mqm
mkdir -p /var/mqm/errors
mkdir -p /var/mqm/trace
mkdir -p /var/mqm/qmgrs
mkdir -p /var/mqm/log
chown -R mqm:mqm /var/mqm - make sure Linux already installed libgcc_s.so and libstdc++.so.6
- update threads-max and nofile setting for system and users
echo 32768 > /proc/sys/kernel/threads-max
ulimit -n 10240
or add below lines into /etc/security/limits.conf for nofile limit:* soft nproc 65535 * hard nproc 65535 * soft nofile 65535 * hard nofile 65535 root soft nproc 65535 root hard nproc 65535 root soft nofile 65535 root hard nofile 65535
- start installation with root:
cd /tmp/MQServer/
./mqlicense.sh -text_only
apt install ./ibmmq-runtime_9.1.5.0_amd64.deb
apt install ./ibmmq-gskit_9.1.5.0_amd64.deb
apt install ./ibmmq-server_9.1.5.0_amd64.deb
apt install ./ibmmq-jre_9.1.5.0_amd64.deb
apt install ./ibmmq-java_9.1.5.0_amd64.deb
apt install ./ibmmq-explorer_9.1.5.0_amd64.deb
apt install ./ibmmq-samples_9.1.5.0_amd64.deb
…..
you can install other packages if you want, but we need at least runtime, gskit and server for a MQ env. - create and start qmgr with mqm ID
su – mqm
cd /opt/mqm/bin
./crtmqm -q -d MY.DEFAULT.XMIT.QUEUE -u SYSTEM.DEAD.LETTER.QUEUE SATURN.QUEUE.MANAGER
./strmqm SATURN.QUEUE.MANAGER
./endmqm SATURN.QUEUE.MANAGER
./dspmq -m SATURN.QUEUE.MANAGER
mqm@ubunu2004:/opt/mqm/bin$ ./dspmq -m SATURN.QUEUE.MANAGER
QMNAME(SATURN.QUEUE.MANAGER) STATUS(Running)
mqm@ubunu2004:/opt/mqm/bin$ ./dltmqm qmgr1
IBM MQ queue manager ‘qmgr1’ deleted. - verify the installation with command
you can setup your default mqm env first:
mqm@ubunu2004:/opt/mqm/bin$ source /opt/mqm/bin/setmqenv -s
then create a new qmgr and putmsg/getmsg:
crtmqm QMA
strmqm QMA
mqm@ubunu2004:~$ runmqsc QMA
5724-H72 (C) Copyright IBM Corp. 1994, 2020.
Starting MQSC for queue manager QMA.
AMQ8521I: Command completion and history unavailable.
DEFINE QLOCAL (QUEUE1)
1 : DEFINE QLOCAL (QUEUE1)
AMQ8006I: IBM MQ queue created.
DEFINE CHANNEL(channel_test) CHLTYPE(CLNTCONN) CONNAME(192.168.0.43)
3 : DEFINE CHANNEL(channel_test) CHLTYPE(CLNTCONN) CONNAME(192.168.0.43)
AMQ8014I: IBM MQ channel created.
DEFINE LISTENER(LISTENER.1414.TCP) TRPTYPE(TCP) PORT(1414)
4 : DEFINE LISTENER(LISTENER.1414.TCP) TRPTYPE(TCP) PORT(1414)
AMQ8626I: IBM MQ listener created.
START LISTENER(LISTENER.1414.TCP)
5 : START LISTENER(LISTENER.1414.TCP)
AMQ8021I: Request to start IBM MQ listener accepted.
end
2 : end
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.
mqm@ubunu2004:~$ cd /opt/mqm/samp/bin
mqm@ubunu2004:/opt/mqm/samp/bin$ ./amqsput QUEUE1 QMA
Sample AMQSPUT0 start
target queue is QUEUE1
this is my test msg.
hi
Sample AMQSPUT0 end
mqm@ubunu2004:/opt/mqm/samp/bin$ ./amqsget QUEUE1 QMA
Sample AMQSGET0 start
message <this is my test msg.>
message <hi>
no more messages
Sample AMQSGET0 end