Queue-Monitoring Agent

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Craig Buchanan

    Queue-Monitoring Agent

    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>


  • Craig Buchanan

    #2
    Re: Queue-Monitoring Agent

    Found a good option:


    "Craig Buchanan" <reply@newsgrou p.comwrote in message
    news:%239EbuVyL JHA.3744@TK2MSF TNGP06.phx.gbl. ..
    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>
    >
    >

    Comment

    Working...