开发者

Java Async REST web service using Jersey?

开发者 https://www.devze.com 2022-12-15 15:22 出处:网络
开发者_JS百科I need to implement a Java REST Web Service (we use Jersey framework) which can basically either

开发者_JS百科I need to implement a Java REST Web Service (we use Jersey framework) which can basically either

a. block waiting for some event (or poll for the event), before returning the response b. provide some kind of aysnc behaviour to notify the client when the request has been processed.

I was thinking of returning a transationID, and having a /status endpoint which the client should poll to determine if the request was processed and get a specific result.

Any ideas?


Alan, the right thing to do is to use HTTP's 202 Accepted return code and include in the response body a link that points to a page the client can poll to check the status of the request.

In a machine2machine context you will need to design your media type (or microformat etc.) for those responses so a machine client can 'understand' them.

See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.3

Maybe also look at the almost standardized new HTTP Link header for that purpose.

https://datatracker.ietf.org/doc/html/draft-nottingham-http-link-header-03

Jan


You might find this interesting: Approach for REST request with long execution time

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号