Comment 3 for bug 730162

Revision history for this message
Dariusz Suchojad (dsuch) wrote :

OK, I still don't know how to properly do it on Python side but I've created two simple C programs for pub/sub with MQSUBRQ, they're in the attachments (retained-put.c & retained-get.c).

Before running them you need to define a topic like that one DEFINE TOPIC(TOPIC.1) TOPICSTR('/topic/1') and compile the programs

$ gcc -Wall -I/opt/mqm/inc -c retained-put.c && gcc ./retained-put.o -L/opt/mqm/lib64 -lmqic_r -o ./retained-put
$ gcc -Wall -I/opt/mqm/inc -c retained-get.c && gcc ./retained-get.o -L/opt/mqm/lib64 -lmqic_r -o ./retained-get

You can then run them like below

$ ./retained-put
Channel: SVRCONN.1
Connection name: 192.168.1.139(1434).

MQCONNX ended with reason code 0
MQOPEN ended with reason code 0
MQPUT ended with reason code 0
MQCLOSE ended with reason code 0
MQDISC ended with reason code 0
$

$ ./retained-get
Channel: SVRCONN.1
Connection name: 192.168.1.139(1434).

MQCONNX ended with reason code 0
MQSUB ended with reason code 0
MQSUBRQ ended with reason code 0
sro.NumPubs: 1
MQGET ended with reason code 0
message <My payload>
MQDISC ended with reason code 0
$

In other words, if we have it working in C then making it work in Python should be doable as well. There are two interesting points:

- retained-put.c uses the name of a topic whereas retained-get.c has to use the topic's string not its name
- I couldn't get it working until I made it two separate programs, it was just one initially but I couldn't issue MQGET without it raising MQRC 2033. It magically disappeared when I made it two programs instead.

Well, it's not much but at least it's a confirmation that the environment works OK. Will try to tackle the Python side now.