473,405 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Parallel Programming

I have a program that needs to run on a regular basis that looks at a
queue table in my database. If there are items in the queue database
I need to grab the data from the database and pass it to a web service
to process. The web service will return either a completion code or
error msg (the only errors expected would be timeout or cannot
connection errors). This queue file can contain 0 to N messages.
Naturally if there are no messages the program terminates. If there
are less than 8 messages in the queue, I will run the program on a
single thread waiting for a response. However, if there are more than
8 messages (indicating a backlog) I would like to process them in
parallel through the server's 8 cores. I have been reading up on the
parallel library and it looks promising. My questions are:

1. Would the parallel processing library be appropriate for this
situation? Could web services be invoked on each "thread" created and
processed?

2. How would I make sure not to access the same record in the
database? I can return a listing of all the queueID's from the
database and pass them in as a parameter (looking a the Parallel.For
or Parallel.Foreach?

3. If this is not a good path to pursue, what other options do you
suggest? I was thinking of threading and calling the services on an
async method, but this has its own issues.

Thanks.

John
Oct 9 '08 #1
3 2864
Hey that program sounds familiair :-)

I have created a program that does exactly what you describe and a bit more
only with that difference that mine is always running in paralel modus
my program is a service by itself ( a windows service ) it checks every 500
miliseconds + N processing seconds if there is anny work to be done ,
if there is work availlable it will create a instance of a worker assembly
( dll with queue interface ) in a seperate thread .
1. Would the parallel processing library be appropriate for this
situation?
Don`t know i created the logic all myself , and it was not that hard + the
extra benefit is that i fully understand what is happening and have full
control
Could web services be invoked on each "thread" created and processed?
Yes as IIS is also multithreaded and webservices are stateless
>2. How would I make sure not to access the same record in the
database? I can return a listing of all the queueID's from the
database and pass them in as a parameter (looking a the Parallel.For
or Parallel.Foreach?
My queue table has a status byte so 0 is in wait modus , 1 is in process
modus , 2 is in cancell modus , 3 is in error state , 4 is finished
however the record is then also removed from the table
3. If this is not a good path to pursue, what other options do you
suggest? I was thinking of threading and calling the services on an
async method, but this has its own issues.
Yes i guess it is , in our production environment it is working this way
since early 2006 the project is recently upgraded to VB 2008 framework 3.5
>I was thinking of threading and calling the services on an
async method, but this has its own issues.
I run my worker objects in a seperate thread als code is encapsulated in a
worker class that implements my queue interface it can comunicate with my
main assembly although it is running in a fire and forget modus on a
seperate thread context , my queue server can run multiple queues
simultaniously

this requires a good interface definition hoever it means that you can write
all your worker code in a "normall" fashion as the whole running object is
in a seperate running thread context .

In my opinion you are on the right path , as it sounds so familiair to
my project i would be a fool to say otherwise ( maybe my boss is reading
this :-) )
are you sure you are not also working for the ista corporation
http://www.ista.com :-)

However so many people so many aproaches for the same task so maybe someone
else has a brighter idea to acomplish this task

HTH

Michel Posseth [MCP]
http://www.vbdotnetcoder.com


"John" <ri**********@hotmail.comschreef in bericht
news:e3**********************************@f63g2000 hsf.googlegroups.com...
>I have a program that needs to run on a regular basis that looks at a
queue table in my database. If there are items in the queue database
I need to grab the data from the database and pass it to a web service
to process. The web service will return either a completion code or
error msg (the only errors expected would be timeout or cannot
connection errors). This queue file can contain 0 to N messages.
Naturally if there are no messages the program terminates. If there
are less than 8 messages in the queue, I will run the program on a
single thread waiting for a response. However, if there are more than
8 messages (indicating a backlog) I would like to process them in
parallel through the server's 8 cores. I have been reading up on the
parallel library and it looks promising. My questions are:

1. Would the parallel processing library be appropriate for this
situation? Could web services be invoked on each "thread" created and
processed?

2. How would I make sure not to access the same record in the
database? I can return a listing of all the queueID's from the
database and pass them in as a parameter (looking a the Parallel.For
or Parallel.Foreach?

3. If this is not a good path to pursue, what other options do you
suggest? I was thinking of threading and calling the services on an
async method, but this has its own issues.

Thanks.

John

Oct 9 '08 #2
On Oct 9, 1:59*pm, "Michel Posseth [MCP]" <M...@posseth.comwrote:
Hey that program sounds familiair :-)

I have created a program that does exactly what you describe and a bit more
only with that difference that mine is always running in paralel modus
my program is a service by itself ( a windows service ) *it checks every 500
miliseconds + *N processing seconds *if there is anny work to be done,
if there is work availlable it will create a instance of a worker assembly
( dll with queue interface ) in a seperate thread *.
1. *Would the parallel processing library be appropriate for this
situation?

Don`t know i created the logic all myself , and it was not that hard + the
extra benefit is that i fully understand what is happening and have full
control
Could web services be invoked on each "thread" created and processed?

Yes as IIS is also multithreaded and webservices are stateless
2. *How would I make sure not to access the same record in the
database? *I can return a listing of all the queueID's from the
database and pass them in as a parameter (looking a the Parallel.For
or Parallel.Foreach?

My queue table *has a status byte *so 0 is in wait modus , 1 is in process
modus , *2 is in cancell modus , 3 is in error state *, 4 is finished
however the record is then also removed from the table
3. *If this is not a good path to pursue, what other options do you
suggest? *I was thinking of threading and calling the services on an
async method, but this has its own issues.

Yes i guess it is , in our production environment it is working this way
since early 2006 the project is recently upgraded to VB 2008 *framework3.5
I was thinking of threading and calling the services on an
async method, but this has its own issues.

I run my worker objects in a seperate thread als code is encapsulated in a
worker class that implements my queue interface it can comunicate with my
main assembly although it is running in a fire and forget modus on a
seperate thread context , my queue server *can run multiple queues
simultaniously

this requires a good interface definition hoever it means that you can write
all your worker code in a "normall" fashion as the whole running object is
in a seperate running thread context .

In my opinion you are on the right path * , as it sounds so *familiair *to
my project *i would be a fool to say otherwise ( maybe my boss is reading
this :-) *)
are you sure you are not also working *for the ista corporationhttp://www.ista.com*:-)

However so many people so many aproaches for the same task so maybe someone
else has a brighter idea to acomplish this task

HTH

Michel Posseth [MCP]http://www.vbdotnetcoder.com

"John" <riley_wri...@hotmail.comschreef in berichtnews:e3**********************************@f 63g2000hsf.googlegroups.com...
I have a program that needs to run on a regular basis that looks at a
queue table in my database. *If there are items in the queue database
I need to grab the data from the database and pass it to a web service
to process. *The web service will return either a completion code or
error msg (the only errors expected would be timeout or cannot
connection errors). *This queue file can contain 0 to N messages.
Naturally if there are no messages the program terminates. *If there
are less than 8 messages in the queue, I will run the program on a
single thread waiting for a response. *However, if there are more than
8 messages (indicating a backlog) I would like to process them in
parallel through the server's 8 cores. *I have been reading up on the
parallel library and it looks promising. *My questions are:
1. *Would the parallel processing library be appropriate for this
situation? *Could web services be invoked on each "thread" created and
processed?
2. *How would I make sure not to access the same record in the
database? *I can return a listing of all the queueID's from the
database and pass them in as a parameter (looking a the Parallel.For
or Parallel.Foreach?
3. *If this is not a good path to pursue, what other options do you
suggest? *I was thinking of threading and calling the services on an
async method, but this has its own issues.
Thanks.
John- Hide quoted text -

- Show quoted text -
Ha, great minds think alike! I to have a status field on my queue
that will change as it progresses through the system. I plan on
making a windows service as well to monitor the queue. Most of the
time if the central system is up and running the queue will never be
full since we want this near real time. However, in those rare
instances when the connection is severed or they roll the main system
back I can re-queue jobs and have them automatically push up again.
Looking at my options, the Parallel class has not fully matured and is
still in CTP state, so I am going to do my own threading. I think
I'll check the number of items in the queue and spawn threads
accordingly with a thread limit to eliminate overloading the server.
Thanks for the encouragement, and no I don't work at ista, but if they
paid enough I just might!

Thanks.
Oct 9 '08 #3
John,

As I made this as well a short while ago in a windows service, is it quite
simple to do in a webservice as well.

The only thing I did, was not using anything to make a difference between 8
or 9.

I simple use in this kind of problems forever the generic Queue class. It
does exactly what is needed to create smooth operations in multithreading

http://msdn.microsoft.com/en-us/library/7977ey2c.aspx

Don't forget to synclock between enqueing and dequing.

Cor

"John" <ri**********@hotmail.comschreef in bericht
news:e3**********************************@f63g2000 hsf.googlegroups.com...
>I have a program that needs to run on a regular basis that looks at a
queue table in my database. If there are items in the queue database
I need to grab the data from the database and pass it to a web service
to process. The web service will return either a completion code or
error msg (the only errors expected would be timeout or cannot
connection errors). This queue file can contain 0 to N messages.
Naturally if there are no messages the program terminates. If there
are less than 8 messages in the queue, I will run the program on a
single thread waiting for a response. However, if there are more than
8 messages (indicating a backlog) I would like to process them in
parallel through the server's 8 cores. I have been reading up on the
parallel library and it looks promising. My questions are:

1. Would the parallel processing library be appropriate for this
situation? Could web services be invoked on each "thread" created and
processed?

2. How would I make sure not to access the same record in the
database? I can return a listing of all the queueID's from the
database and pass them in as a parameter (looking a the Parallel.For
or Parallel.Foreach?

3. If this is not a good path to pursue, what other options do you
suggest? I was thinking of threading and calling the services on an
async method, but this has its own issues.

Thanks.

John
Oct 10 '08 #4

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

Similar topics

0
by: Yuancai \(Charlie\) Ye | last post by:
Hi, All: I am happy to annouce that we have formally released our latest SocketPro version 4 at www.udaparts.com, an advanced remoting framework written from batching/queue, asynchrony and...
10
by: Joshua Nussbaum | last post by:
I came up with what I think is a good idea for making multithreading programming easier in any .NET language. I dont know where else to post it, so I'll try here. ..NET 2.0 adds the capability...
10
by: bpontius | last post by:
The GES Algorithm A Surprisingly Simple Algorithm for Parallel Pattern Matching "Partially because the best algorithms presented in the literature are difficult to understand and to implement,...
9
by: MNQ | last post by:
Hi All I want to use my parallel port of my PC to control some external devices. I am writing a program in ANSI C using the PacificC compiler. What I need to know is how to access the parallel...
3
by: paytam | last post by:
Hi all, Is it possible to write parallel programming in C? I mean for example a simple program like I have a clock on a program that show me current time and and at the same time another job like...
126
by: ramyach | last post by:
Hi friends, I need to write a parallel code in 'C' on the server that is running SGI Irix 6.5. This server supports MIPS Pro C compiler. I don't have any idea of parallel C languages. I looked...
0
by: fiepye | last post by:
Hello. I am interested in parallel computing in Python. Except other modulesI would like to use new modules for vector and matrix operations and scientific computing SciPy and NumPy. I have...
26
by: Prime Mover | last post by:
Hello all, I have got the pseudo-code below that I would like to convert to c language. The algorithm calculates Pi value. I am somewhat familiar with C language, but I am just starting to learn...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.