Home REST: Processing error in long running operation, how to inform clients?
Reply: 1

REST: Processing error in long running operation, how to inform clients?

Pontius Glaw
1#
Pontius Glaw Published in 2017-12-07 06:56:22Z

I am developing a webservice that alllows users to request validation reports. Report generation might take up to 20 hours per report. When a new validation request is posted, I return a 202 Accepted answer with Location set to a processing queue (e.g./queue/5) When the queue resource is polled some processing information is provided:

<queueResponse> <status>QUEUED</status> <queuePosition>1</queuePosition> </queueResponse>

Once processing completes successfully and the queue is polled, a 303 see other will redirect to the created resource (at /reports/5 e.g.).

However if a processing error occurs on server, i simply return my queueResponse without redirect and status set to <status>ERROR</status>.

Is this the best way to comunicate a processing error to the client? Or should instead simply a 500 Internal Server Error returned when polling the queue for a failed validation task?.....

Nicholas Shanks
2#
Nicholas Shanks Reply to 2017-12-09 10:44:53Z

Your current solution is best. A 500 error for the queued process information would indicate that the request for that resource had failed, not the process it was reporting on.

postscript: If your API is still being defined, I would suggest FAILED instead of ERROR, as it sounds more permanent. Errors are potentially recoverable situations, failures are not.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.297227 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO