Reputation: 23
I need to create a service which will handle long executing jobs. Currently I am trying to develop WebAPI REST service with, for example, endpoint "POST /api/start", which will return JobId. After that I will be polling service using some other endpoint like "GET /api/status/{jobId}".
The issue is that REST service cannot have state or at least it is not good practice. Maybe you could suggest me some of the good ways of separating service from an actual JobHandler? Or, if it is okay to do this in WebAPI, explain how to create singletone, which will not be disposed until IIS is reset.
Thank you.
UPDATE: After all investigation I decided to create WebAPI REST Service to communicate with client and for long executing jobs I developed WindowsService with WCF communication layer. It is the best solution I could find and it suits me very well. Thanks everybody.
Upvotes: 1
Views: 631
Reputation: 11
This may be helpful.
If you want to stick with polling, you should create a new REST resource, which contains the actual state and the progress of the long running task.
Upvotes: 1