3 Replies Latest reply on Jun 29, 2011 12:10 PM by marim

    Scalability in CXF

    marim

      Hi,

       

      I am developing application which publish CXF RESTful web service. Problem with scalability is that incoming requests very often must wait for others things to occur and timeout is a quite normal thing.

       

      Is there any feature which enable processing this requests asynchronous on cxf side? By asynchronous I mean to save somewhere request and when response came return it to client within saved request? It would result in not blocking cxf threads until response will be ready.

       

      I am using Camel for passing and routing messages if it matter.

        • 1. Re: Scalability in CXF
          ffang

          Hi,

           

          Sounds like you need use async camel-cxf endpoint which use cxf continuation api underlying.

          Which camel version you're using?

           

          Freeman

          • 2. Re: Scalability in CXF
            njiang

            camel-cxf is based on the cxf runtime and CXF supports the async invocation out of box.

            If you are using CXF Jetty Http transport,  you can leverage the continuation to prepare the response message without blocking the underlay transport thread.

             

            But if you are using other transport, such as Servlet transport, you need to check if the web container has this kind function.

             

            Willem

            • 3. Re: Scalability in CXF
              marim

              It took quite a long time since first post but I have got another question about async invocations in cxf and camel.

               

              My app take a long time to return so connection can fail/timeout before response is ready. Is there any way to detect that connection has been closed?

               

              I am using camel-cxf approach with

               

              (...)

              .process(new AsyncProcessor(){

              public boolean process(Exchange exchange, AsyncCallback callback) {
              (...)
              return false;
              }

              }

               

              there are methods like:

               

              exchange.isFailed() - but it always returns false even when I close connection on the second side

               

              similiar here:

              exchange.addOnCompletion(new Synchronization() {                                   

                                                 public void onFailure(Exchange exchange) {

                                                      // never

                                                 }

                                                  

                                                 public void onComplete(Exchange exchange) {

                                                      // always

                                                 }

                                            });