4

My Web Service uses another API to obtain data. I cache the data, clean it and return it do the user when they make a request. At the moment I am getting a lot of requests and because I can only access the data API 2 times per second, I am getting errors back which means some users don't get the data and other do.

What I want to do is add each request to a queue and process them 1 by one with a 0.4 second sleep between them. he queue would have to be running all the time to make sure that all request are processed.

How would I do this in ASP.NET 3.5?

Simeon Wislang
  • 461
  • 2
  • 9
  • 21

1 Answers1

6

Briefly, I suggest you create a Windows Service to process an MSMQ queue. Your existing web service would put requests into that queue.

However, your service will need to become an asynchronous web service. This way, while "waiting" for a response, your service will not be blocking a request thread.

BTW, are you using ASMX web services or WCF services? This will determine how to make the service asynchronoous.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
  • To be honest I am actually just using an MVC view page that returns JSON based on the details in the URL. The mvc controller gets the variables and sends a list of items to the viewpage for it to display. Is it really necessary to have a standalone Web Service to handle the requests? If so what type of service do you think would be best. – Simeon Wislang Jun 22 '09 at 07:18
  • Didn't you say you needed to queue the requests? – John Saunders Jun 22 '09 at 12:24
  • Yes, I need something to queue and handle them. – Simeon Wislang Jun 25 '09 at 05:31