Continuations
{span:style=font-size:2em;font-weight:bold} Continuations {span} Wiki Markup
Table of Contents |
---|
Continuations API
CXF offers Continuations API to manage asynchronous (suspended) invocations.
ContinuationProvider represents a transport capable of suspending and resuming the invocations on request.
CXF offers Servlet3 and legacy Jetty Continuations HTTP as well as JMS ContinuationProvider implementations.
ContinuationProvider can be used to get Continuation which represents a current active or suspended invocation.
The provider and continuations can be obtained from the current CXF message like this:
Code Block | ||||
---|---|---|---|---|
| ||||
import org.apache.cxf.continuations.ContinuationProvider;
import org.apache.cxf.continuations.Continuation;
ContinuationProvider provider = (ContinuationProvider)message.get(ContinuationProvider.class.getName())
Continuation continuation = provider.getContinuation();
|
...
Calling Continuation.suspend() and returning from the current method/code is enough to get CXF suspending the request. Additionally throwing SuspendedInvocationException was required originally but is no longer required/recommended.
...
Advanced applications can register ContinuationCallback with the current exchange in order to get the notifications that a given Continuation has completed its work by returning the data to the client.
...
Advanced custom CXF interceptors can suspend the incoming requests and resume them when needed.
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
//TODO
|
Enabling HTTP continuations
...