You can try using RestEasy.
In RestEasy you can bind a handler before and after a REST call has been executed.
You can than store a REST call on the before handler and acknowledge the execution once finished.
If the REST was not executed ... it can be retried, or it's action repeated.
The code would look something like this (REQUEST):
@Provider
public class RestInterceptor implements ContainerRequestFilter {
@Override
public void filter(ContainerRequestContext context) {
(RESPONSE)
@Provider
public class EventFilter implements ContainerResponseFilter {
@Override
public void filter(ContainerRequestContext containerRequestContext, ContainerResponseContext containerResponseContext) throws IOException {
The question arises WHY?
REST calls should be simple atomic tasks executed in less than 30s.
Plus they should be (if possible) idempotent.
If you would like to trigger and monitor long running tasks with REST calls then this is the way to go. But the job itself should be separated and monitored on some other level (not the HTTP stack).