Our process needs to read messages from a topic on the local Q manager and also write to a different topic on the same local Q manager.
To read messages we have used MQCB
. The messages reach the callback function of the process. However, while the callback remains registered, we are not able to MQPUT
messages to a different topic.
We get an error that says:
2500 : MQRC_HCONN_ASYNC_ACTIVE
An attempt to issue an MQI call has been made while the connection is started
Apparently, a single connection handle cannot be used to both read and write. We have to Suspend the MQCB
, MPUT
the message and Resume the MQCB
to get it to work.
Is there a way to avoid having to suspend and resume?
Thanks in advance
Yes, that is the expected behavior when using MQCB. Two approaches you can take:
1) Create another connection to the same queue manager to publish messages.
2) If your design is to publish messages whenever you receive a message on the callback function, then publish messages from callback function itself.
Update
MQRC_ALREADY_CONNECTED (2002) issue: What MQCNO_HANDLE_SHARE_* option have you used? Suggest you to use MQCNO_HANDLE_SHARE_BLOCK option to get around this problem. I wrote a sample program and created two connections on the same thread by using MQCNO_HANDLE_SHARE_BLOCK option.