Skip to content

Instantly share code, notes, and snippets.

@abhirockzz
Last active April 3, 2016 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhirockzz/0f8263db676a438ec23cf2a296769875 to your computer and use it in GitHub Desktop.
Save abhirockzz/0f8263db676a438ec23cf2a296769875 to your computer and use it in GitHub Desktop.
Custom HTTP response on request time out
@GET
public void async(@Suspended AsyncResponse ar) {
ar.setTimeout(3, TimeUnit.SECONDS);
ar.setTimeoutHandler(new TimeoutHandler() {
@Override
public void handleTimeout(AsyncResponse asyncResponse) {
asyncResponse.resume(Response.accepted(UUID.randomUUID().toString()).build()); //sending HTTP 202 (Accepted)
}
});
......
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment