Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all, the title of the question may not clear enough, allow me to explain the background here:

I would like to design a web service that generates PDF and submit it to printer, here is the workflow:

1. User submit a request to the web service, probably the request will be one off so that user wouldn't suffer from waiting the job complete. User may received a HTTP200 and continue their work.

2. Once web service received the request, as I don't want the drain all resource on that server, I may use producer consumer pattern here, there might be a queue to to queue client jobs, and process them one by one.

My Questions is that:
1. I'm new to C#, what is the proper pattern to queue and process them? Should I use ConcurrentQueue and ThreadPool to archive it?

2. What is the proper way to notify user about the job is success/fail? Instead of using callback service, is async an ideal way? My concern is that there may be lots of jobs in the queue and I don't want client suffer from waiting it complete.

3. The web service is placed behind a load balancer, how can I maintain a 'process queue' among them? I've tried using Hangfire and it seems okay, any alternative suggest?

4. How can I know how many jobs are in the Queue/ how may thread is currently running? The webservice will be deployed on IIS, is there a Native way to archive it, or should I implement a web service call to obtain them?

Any help will be appreciated, thanks!

What I have tried:

For prototype, now I will just create a new thread on each request to process client request. However there is no way the user know the request is success or not.
Posted
Updated 10-Feb-19 21:12pm
Comments
[no name] 9-Feb-19 17:00pm    
Sounds like you're reading a script. If you understood what you were asking you wouldn't be asking half of it.

1 solution

Quote:
1. I'm new to C#, what is the proper pattern to queue and process them? Should I use ConcurrentQueue and ThreadPool to archive it?

2. What is the proper way to notify user about the job is success/fail? Instead of using callback service, is async an ideal way? My concern is that there may be lots of jobs in the queue and I don't want client suffer from waiting it complete.

3. The web service is placed behind a load balancer, how can I maintain a 'process queue' among them? I've tried using Hangfire and it seems okay, any alternative suggest?

4. How can I know how many jobs are in the Queue/ how may thread is currently running? The webservice will be deployed on IIS, is there a Native way to archive it, or should I implement a web service call to obtain them?


1. There are many different but equally valid ways to solve a problem in programming. As the designer it's up to you to determine which way solves the problem in a way that you can both understand and implement, based on the provided specifications if there are any.

2. Again there is no 'proper way' and if you;re asked ot develop something then the required way should be in the specification. You could use webhooks for call backs, you could use SMS or E-Mail if you're notifying an end user, all valid notification methods depending on the requirements.

3. Hangfire is a great tool, I'm a big fan, alternatively, options such as message queues/busses may also be worth considering.

4. Hangfire or message busses will have a count of jobs in the queue that would be available. You'd need to queries these, IIS would not store this information.

Good luck!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900