|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
file descriptor and select() for MQ |
« View previous topic :: View next topic » |
Author |
Message
|
skytorch |
Posted: Tue Jul 23, 2002 10:06 am Post subject: file descriptor and select() for MQ |
|
|
 Apprentice
Joined: 10 Jun 2002 Posts: 47 Location: New York City
|
Hi,
We've a MQ Client in C that use MQ5.2 QM on solaris 7. This client is a single threaded to read from a socket connection and a app queue Q1.
If a message comes from the socket, it'll send message to some app queues; if a message comes to Q1, it'll send it to the socket connection.
Since the application is single threaded, in order to improve the system performance, both reads from socket and Q1 should better be in non-block manner.
I wonder if I can use unix select(<file descriptors>) to monitor both socket connection and a Q1 within one thread. If a message shows up in either one, I can process it.
Is it do-able with MQ Queue ?
Thanks.
Sky |
|
Back to top |
|
 |
kolban |
Posted: Tue Jul 23, 2002 11:13 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2001 Posts: 1072 Location: Fort Worth, TX, USA
|
Unfortunately not. If you could allow yourself to be multi-threaded, you could have a thread that blocks on the socket and a thread that blocks on the queue with an MQGET call. Unfortunately, there is no asynchronous delivery mechanism to notify you that a message is available when you do an MQGET call.
You could do a blocking MQGET call with a small delay (say 1000 ms or less) and, if awoken because there was no message, then do a block on the socket for a 1000 ms and repeat.
This would be a loose kind of polling but not so inefficient that the resources consumed would be too high.
You could also go multi-process if multi-threading isn't possible. Have a second, demon program, block indefinietly on the queue and, when a message is available, consume the message and then send it down a socket to be consumed by the blocked main thread/process. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|