CXF continuation - Async server and async client in Fuse

Solution Verified - Updated -

Issue

  • We are developing a web service application based on CXF. As this webservice will be heavily used and we are depending on third party services, we want to process requests fully asynchronously.
    Our webservice is used the same way as a proxy. We receive a request from the customer, we do some checks on the request and we forward it to a third-party webservice.
    When we get the response, we forward it back to the customer.

  • Here is the first scenario that is working fine. We are using CXF continuation to suspend/resume the request.

    • The Jetty server receives a request from the customer
    • We create an AsyncHandler to handle the request asynchronously
    • In our AsyncHandler, by using an asynchronous client, we modify and forward the request to the third party web service.
    • The call returns directly (as it is asynchronous) and we suspend the CXF continuation
    • When the CXF client gets the response, it goes back it the AsyncHandler (handleResponse method) where we resume the continuation
  • However, this scenario is not meeting perfectly our requirements. Before forwarding the request to the third party web service, we need to sign the request and we need to do that asynchronously as well as it has to be signed by another third party service.
    So, basically, we have to suspend the continuation in the client (e.g. in a CXF InInterceptor set on the client). However, it doesn’t seem that CXF allows the client to get the continuation as there is no straightforward way to do it.

  • So we have attached the continuation is to the client request context.

Map<String, Object> requestContext = ((javax.xml.ws.BindingProvider) client).getRequestContext();
requestContext.put("myContinuation", continuation) ;
  • However, if we suspend the continuation in the client CXF interceptor, the continuation does not seem to be suspended… The request is directly forwarded to the third-party web service before having being signed.

  • Is it possible to suspend/resume the continuation multiple times and this has to be done on the server side but as well on the client side?
    How can we achieve this kind of scenarios with CXF? We need to be fully asynchronous on the client and server side of our application.

Environment

  • Red Hat JBoss Fuse
    • 6.x
  • Apache CXF

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content