J
John
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
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