2 Replies Latest reply on Dec 7, 2015 1:54 PM by ozkin

    Response is not returned from Camel's onException handler

    ozkin

      Simple test application has one composite service with HTTP binding and one Camel route implementing the service.

      The route has own exception handling and transforms the response to "error" string in case if an exception is caught.

      For some reason the response is not returned back to the client (via HTTP binding) and client gets hang waiting for the response. Any idea why is that?

      Below is the route definition. I have also attached a complete project. SwitchYard version is 1.1.

      The idea is to return a different custom response in case of an exception..

       

      public void configure() {

              from("switchyard://TestService")

                  .onException(Exception.class)

                      .handled(true)

                      .log("Exception: ${exception}")

                      .transform().simple("error")

                  .end()

                  .log("Received message for 'TestService' : ${body}")

                  .process(new Processor() {

                      @Override

                      public void process(Exchange exchange) throws Exception {

                          throw new Exception("failed");

                      }

                  });

          }

        • 1. Re: Response is not returned from Camel's onException handler
          igarashitm

          I tried it on current upstream master of SwitchYard and got this

          [tomo@tomo-t530 switchyard-http-test]$ telnet localhost 8080

          Trying 127.0.0.1...

          Connected to localhost.

          Escape character is '^]'.

          GET /foo HTTP/1.0

           

          HTTP/1.1 200 OK

          Server: Apache-Coyote/1.1

          Content-Length: 5

          Date: Mon, 07 Dec 2015 00:48:21 GMT

          Connection: close

           

          error

           

          And server log

          09:48:21,953 INFO  [route1] (http-/127.0.0.1:8080-1) Received message for 'TestService' :

          09:48:21,958 INFO  [route1] (http-/127.0.0.1:8080-1) Exception: java.lang.Exception: failed

           

          It seems to be working as expected?

          • 2. Re: Response is not returned from Camel's onException handler
            ozkin

            As I mentioned we use version 1.1.0.Final. Then it seems there is a bug in that version... (

             

            For me the following does not come at all:

             

            HTTP/1.1 200 OK

            Server: Apache-Coyote/1.1

            Content-Length: 5

            Date: Mon, 07 Dec 2015 00:48:21 GMT

            Connection: close

             

            error

             

            And eventually SwitchYard logs:

             

            20:49:33,265 ERROR [org.switchyard.component.http] (http-/127.0.0.1:8080-1) SWITCHYARD036004: Unexpected Exception invoking SwitchYard service: org.switchyard.component.common.DeliveryException: SWITCHYARD034508: Timed out waiting on OUT Exchange message.

                at org.switchyard.component.common.SynchronousInOutHandler.waitForOut(SynchronousInOutHandler.java:83) [switchyard-component-common-1.1.0.Final.jar:1.1.0.Final]

                at org.switchyard.component.common.SynchronousInOutHandler.waitForOut(SynchronousInOutHandler.java:52) [switchyard-component-common-1.1.0.Final.jar:1.1.0.Final]

                at org.switchyard.component.http.InboundHandler.invoke(InboundHandler.java:119) [switchyard-component-http-1.1.0.Final.jar:1.1.0.Final]

                at org.switchyard.component.http.HttpGatewayServlet.handle(HttpGatewayServlet.java:143) [switchyard-component-http-1.1.0.Final.jar:1.1.0.Final]

                at org.switchyard.component.http.HttpGatewayServlet.service(HttpGatewayServlet.java:114) [switchyard-component-http-1.1.0.Final.jar:1.1.0.Final]