Posted: Wed Jul 02, 2008 5:02 am Post subject: MQI calls in multi threaded application
Novice
Joined: 06 Sep 2005 Posts: 19
Hi all,
I have an application that uses 2 queues to communicate to a server. One input queue and another output queue. I have 2 threads in my program. The worker thread keeps calling MQGET on the input queue in a loop with a wait interval of 10 seconds. When a message arrives, it updates the UI with the information. The UI thread based on user interaction keeps sending requests to the server through the output queue. The server can keep sending updates even without requests from the application and UI is supposed to show it without any delay.
I tried same thing in .NET (IBM.MQI) and then using C API.
Using .NET:
I opened the MQ connection in the worker thread. The same connection object was used for Get calls in the worker thread, as well as Put calls from the UI thread. This worked in the .NET program using IBM.MQI but putting the message in the output queue from UI thread took a few seconds to return. When I changed the wait interval of the Get call in worker thread to zero, there was no delay in MQPUT and it returned immediately but there was a lot of undesirable network traffic due to continuous Get calls. I don’t want to use a wait interval of less than 10 seconds to minimize network traffic.
Using C API:
When I did the same stuff in a C++ program, it gives an invalid connection handle in the UI thread.
I need to make an interactive application without any visible delays to the user while sending and receiving messages to the server.
Can anyone please explain me how MQ connections creation, getting and putting should be done in 2 different threads so that one thread can keep sending messages to a queue and another thread can keep receiving messages from another queue without introducing a delay?
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum