none
Is it possible to create infinetly running background thread to populate a Queue in a web service? RRS feed

  • Question

  • hosting MVC Web API Rest service in IIS 7

    C# is the language

    Scenario: I want to query a table every minute and populate a queue of a fixed size with results from query. The queue would live in a web service. From there users could query said web service for data currently in the queue. Lets say the queue max size is 50. And the queue would hold custom object. This custom object would hold real time hourly data to be served to a UI. This may not be the best approach. The reason for the queue is I simply don't care about anything except the current hour. Another potential issue is IIS itself. Since IIS is made to be scalable it could possibly create another instance of the web service. I'm open to any suggestions.

    Thanks

    Friday, February 8, 2013 9:04 PM

Answers

  • Try using Timer in your service ( or some kind of custom scheduler ) which would let you pick and populate items in the queue from database at particular intervals.

    In the Tick event of the timer you can check wether there is any space in the queue for new items otherwise you can let go for that instant and check the next time the event gets fired.

    Thanks,

    BR,

    JollyWagoner


    Tuesday, February 12, 2013 4:28 PM