Queue-Monitoring Agent

C

Craig Buchanan

I am trying to develop a queue-monitoring agent. The queue will be either
MSMQ or Amazon's SQS. The message will contain instructions on how a worker
should process (could be lengthy) a file (could be large). The agent's
timing mechanism is disabled until all messages are processed. Currently,
this worker processes messages synchronously. I would like to use a pool of
worker to process the messages asynchronously. The challenge, I am finding,
is how to wait for the pool's next free worker. I've included the
pseduo-code for review. Any thoughts on the pattern would be appreciated.
Thanks,

Craig Buchanan

<SINGLE WORKER>

Sub Timer_Elapsed

disable timer

'drain the queue
while queue has messages

get next message from the queue

process the message synchronously

loop

enable timer

End Sub

</SINGLE WORKER>

<POOL OF WORKERS>

Sub Timer_Elapsed

disable timer

'drain the queue
wait for the next free worker from pool

get the next message from the queue

process the message asynchronously, on another thread

loop

enable timer

End Sub

Sub Processed As IAsyncResult

return the worker to the pool

End Sub

</POOL OF WORKERS>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top