473,659 Members | 2,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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>
Oct 16 '08 #1
1 1284
Found a good option:
http://vasters.com/clemensv/default,...004-12-11.aspx

"Craig Buchanan" <re***@newsgrou p.comwrote in message
news:%2******** ********@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>


Oct 18 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2776
by: phil | last post by:
And sorry I got ticked, frustrating week >And I could help more, being fairly experienced with >threading issues and race conditions and such, but >as I tried to indicate in the first place, you've >provided next to no useful (IMHO) information to >let anyone help you more than this This is about 5% of the code. Uses no locks.
16
12679
by: newsock | last post by:
What differences between queue, deque and priority_queue? And under what situations choose one of them to use? Thanks for your help!
9
2490
by: Brian Henry | last post by:
If i inherite a queue class into my class, and do an override of the enqueue member, how would i then go about actually doing an enqueue of an item? I am a little confused on this one... does over ride just add aditional code ontop of the current class or completely over ride it in vb? I am use to C++ this is the first inherited thing I've done in VB.NET... I'm a little unsure of diffrences, could someone explain this to me some? thanks!
3
5147
by: Kceiw | last post by:
Dear all, When I use #include "queue.h", I can't link it. The error message follows: Linking... G:\Projects\Datastructure\Queue\Debug\main.o(.text+0x136): In function `main': G:\Projects\Datastructure\Queue\main.cpp:16: undefined reference to `Queue<char>::Queue()' G:\Projects\Datastructure\Queue\Debug\main.o(.text+0x394): In function `Z10do_commandcR5QueueIcE':
5
3111
Rooro
by: Rooro | last post by:
Hello everyone i'm working on : " Familiar childhood games such as hide and Go Seek and Tag involve determining the player who is to be "It". One method has the players stand in a circle while one of the players recites some rhyme to count off players, eliminating every nth player, where n depends on the number of the syllables in the counting rhyme. This process stops when only one player, the one to be "It" remains. This process...
2
2954
by: lavender | last post by:
When define a maxQueue is 10, means it able to store 10 items in circular queue,but when I key in the 10 items, it show "Queue Full" in items number 10. Where is the wrong in my code? Why it cannot store up to 10 items? Output from my code: Enter you choice: 1 Enter ID document to print : 21 Enter you choice: 1 Enter ID document to print : 22
3
2031
by: jrpfinch | last post by:
I have a script which is based on the following code. Unfortunately, it only works on Python 2.3 and not 2.5 because there is no esema or fsema attribute in the 2.5 Queue. I am hunting through the Queue.py code now to try to figure out how to make it work in 2.5, but as I am a beginner, I am having difficulty and would appreciate your help. Many thanks Jon
4
4595
by: j_depp_99 | last post by:
Thanks to those guys who helped me out yesterday. I have one more problem; my print function for the queue program doesnt work and goes into an endless loop. Also I am unable to calculate the length of my queue. I started getting compilation errors when I included a length function. <code> template<class ItemType> void Queue<ItemType>::MakeEmpty() {
2
2927
by: ecestd | last post by:
how do you implement a copy constructor for this pointer-based ADT queue #include <cassert // for assert #include <new // for bad_alloc using namespace std; //private:{Queue::Queue(const Queue& Q)}
0
2735
by: ecestd | last post by:
I did implement the copy constructor but still have a problem with it. It is not working. What could be wrong? #include "QueueP.h" #include <cassert // for assert #include <new // for bad_alloc #include <iostream> //typedef std::queue<QueueItemTypeQueue; using namespace std; //private:{Queue::Queue(const Queue& Q)}
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8630
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4176
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4342
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2759
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.