Wednesday, 20 September 2017

Async-Rest API


How to handle a long job in a Rest API? A task may take a long time to compute and therefore resource may not be ready at once.

In such case, rest controller may feedback request by an HTTP status, i.e. accepted and a task token, meanwhile, it spawns a thread to carry out this long job. Once the job is done, the result will be put a queue or a database, where it waits for the user to fetch it.

A client may use task token to check the job status, (in processing, or completed); Once it is completed, the client may use the token to query the result back.

References:
https://farazdagi.com/2014/rest-and-long-running-jobs/
http://www.nurkiewicz.com/2013/03/deferredresult-asynchronous-processing.html

Can Jackson Deserialize Java Time ZonedDateTime

Yes, but must include JSR310. Thus ZonedDateTime can be deserialized directly from JSON response to POJO field. <dependency> <g...