I'm working on a RESTfull web service that does the following:
- On POST request, it starts a long running task. It queues up a message for MSMQ, which is processed in windows service hosted applicaiton. It returns HTTP status code 202 Accepted along with id of the job we queued up.
- Client application continously polls the service (with GET) with id of the job we just queued up. When the MSMQ client is finished with the task, it should return the result of the operation. If not, it will return 202 Accepted with appropriate expiration date for next recommended poll.
My question is: How should I implement communication from MSMQ to web service? Specifically, how would my web service know if a message was processed by MSMQ client?
My first though was to have a "job" table in SQL database which would contain a JobId, a flag indicating whether a job is finished and a result of computation. MSMQ application would then write to this table when it finishes a job, while web service would query the database for status of a job on each request. I don't like this approach very much, as my web service would not use SQL server otherwise - results of the job are idempotent (but time consuming) and I don't intend to save the data it returns in any way.
I'm wondering if there is more idiomatic approach to this problem, as it's the first time I'm dealing with MSMQ or message queues in general.