unmigrated-inline-wiki-markup |
---|
{span:style=font-size:2em;font-weight:bold} Continuations {span} |
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 | ||||
---|---|---|---|---|
| ||||
{toc} h1. Continuations API CXF offers Continuations API to manage asynchronous (suspended) invocations. [ContinuationProvider|http://svn.apache.org/repos/asf/cxf/trunk/core/src/main/java/org/apache/cxf/continuations/ContinuationProvider.java] 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|http://svn.apache.org/repos/asf/cxf/trunk/core/src/main/java/org/apache/cxf/continuations/Continuation.java] which represents a current active or suspended invocation. The provider and continuations can be obtained from the current CXF message like this: {code:java} import org.apache.cxf.continuations.ContinuationProvider; import org.apache.cxf.continuations.Continuation; ContinuationProvider provider = (ContinuationProvider)message.get(ContinuationProvider.class.getName()) Continuation continuation = provider.getContinuation(); {code} The continuation can be suspended and resumed. Calling |
The continuation can be suspended and resumed.
Calling Continuation.suspend()
...
and
...
returning
...
from
...
the
...
current
...
method/code
...
is
...
enough
...
to
...
get
...
CXF
...
suspending
...
the
...
request.
...
Additionally
...
throwing
...
...
was
...
required
...
originally
...
but
...
is
...
no
...
longer
...
required/recommended.
...
Resuming
...
the
...
continuation
...
will
...
get
...
the
...
suspended
...
thread
...
returning,
...
this
...
is
...
typically
...
done
...
by
...
a
...
thread
...
which
...
has
...
completed
...
an
...
asynchronous
...
task.
...
Advanced
...
applications
...
can
...
register
...
...
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.
...
The
...
custom
...
applications
...
can
...
interact
...
directly
...
with
...
Continuations
...
API.
...
CXF
...
also
...
offers
...
higher-level
...
support
...
for
...
asynchronous
...
invocations
...
built
...
on
...
top
...
of
...
Continuations
...
API.
...
UseAsyncMethod
JAX-WS
...
frontend
...
supports
...
this
...
annotation,
...
please
...
check
...
the
...
...
...
page
...
for
...
more
...
information.
...
JAX-RS
...
2.0
...
AsyncResponse
...
JAX-RS
...
2.0
...
AsyncResponse
...
is
...
implemented
...
in
...
terms
...
of
...
Continuations
...
API.
...
Please
...
see
...
...
...
for
...
more
...
information.
...
Suspending invocations from CXF interceptors
Advanced custom CXF interceptors can suspend the incoming requests and resume them when needed.
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
//TODO
|
Enabling HTTP continuations
Make sure CXFServlet is supporting the asynchronous requests, check the Servlet Transport page for more information.