I am using IBM MQ (version 9.3.0.16) redistributable libraries for Linux to setup a communication channel between Queue Manager and my sample C++ application. My goal is to get messages asynchronously from a queue. I can read the message synchronously using get()
call in a blocking manner (inside a while-loop), limiting the performance and speed. Therefore, I need to use asynchronous ways for reading the message.
As per my research, I found no direct functions in C++ classes to read messages asynchronously or define a callback. However, I found out that there is a way to achieve this using C-based method.
I have found a utility that is said to achieve the same task. I have compiled it but when I executed it, I got an error when I registered a callback using MQCB()
function call as below:
MQCB ended with reason code: 2012
According to utility and from ChatGPT, it is suggested to change the Shared Connections parameter in Queue Manager to 10 which I have already tried but I am still getting the same error.
Below are the URL of the gist that contains the .c code I am running: Code link
Just an FYI, the Queue Manager is running in a docker container which I got up and running using below URL: Queue Manager
I am out of ideas and require help.
I tried changing the Shared Connection parameter but it didn't work. I am still getting the same error.
You need to compile with the threaded options. In particular link with the _r versions of the MQ libraries. For example
cc -o myprog myprog.c -L/opt/mqm/lib64 -I/opt/mqm/inc -lmqm_r
If you don't do that you usually get either 2012 (when running in client mode) or 2488 (running in local bindings mode).