Creating a dynamic response queue

Asked by garys

I am trying to convert existing VB DLL code to Python for MQ using pymqi. I have converted all the functions I require except a function for creating a dynamic response queue. In all honesty I am flunking badly. Below is what I am trying to move from VB to Python.

What works in VB:
MQOD_DEFAULTS RepQ_OD
RepQ_OD.ObjectName = "D3000.REPLY.QUEUE.MODEL"
RepQ_OD.DynamicQName = 'DYNAMIC.REPLY*'
OpenOptions = MQOO_INPUT_EXCLUSIVE

In VB the following line return gets the dynamic queue name from the host:

MQOPEN Hconn, RepQ_OD, OpenOptions, Hrep, CompCode, Reason

And the ObjectName has been replaced with the new dynamic queue name

msResponseQueueName = RTrim$(RepQ_OD.ObjectName)

What I am attempting in Python:
recQOD = pymqi.od()
recQOD.set(ObjectName = "D3000.REPLY.QUEUE.MODEL")
recQOD.set(DynamicQName = 'DYNAMIC.REPLY*')
openOptions = pymqi.CMQC.MQOO_INPUT_EXCLUSIVE

How do I trigger an MQOPEN? I can’t figure out how put the parts together and I’m not understanding the docs.

Thank you

Gary

Question information

Language:
English Edit question
Status:
Solved
For:
PyMQI Edit question
Assignee:
No assignee Edit question
Solved by:
Dariusz Suchojad
Solved:
Last query:
Last reply:
Revision history for this message
Best Dariusz Suchojad (dsuch) said :
#1

Hi,

if I understood you correctly, would that be a piece of code you were looking for? Can you, please, try it and let me know?

Thanks!

import CMQC
import pymqi

# Connection info.

qm_name = "QM01"
channel = "SVRCONN.1"
conn_info = "192.168.1.121(1435)"

# Message we'll be passing around.
msg = "Hello, dynamic queue!"

# Conect to MQ.

cd = pymqi.cd()
qm = pymqi.QueueManager(None)
qm.connectTCPClient(qm_name, cd, channel, conn_info)

# Prepare an object descriptor for dynamically creating a queue.

od = pymqi.od()
od.ObjectName = "D3000.REPLY.QUEUE.MODEL"
od.DynamicQName = "DYNAMIC.REPLY.*"

# Open the queue for reading.

input_open_options = CMQC.MQOO_INPUT_EXCLUSIVE
input_queue = pymqi.Queue(qm, od, input_open_options)
dyn_queue_name = od.ObjectName.strip()

print "Successfully created a dynamic queue", dyn_queue_name

# Open the queue again and put a message on it.

output_queue = pymqi.Queue(qm, dyn_queue_name)
output_queue.put(msg)

print "Successfully sent a message [%s]" % msg

# Now get the message off the queue.

received_msg = input_queue.get()
print "Successfully received a message [%s]" % received_msg

Revision history for this message
garys (gary-scorby) said :
#2

Works perfectly Dariusz. Thanks so much for your help.

Gary