5 Replies Latest reply on May 22, 2013 8:55 PM by hisao.furuichi

    Question about errorHandler for switchyard.xml

    hisao.furuichi

      Hello

       

      I'm researchng about errorHanlder. Here is what I'm trying to do.

      ~~

      Define a specific errorHandler for <bean/> or <route/> in switchyard.xml to customize behavior of a service for Exception.

      ~~

      Could someone please point me out where I should check?  Any info would be appreciate.

       

      Thanks

        • 1. Re: Question about errorHandler for switchyard.xml
          splatch

          You may use CDI together with Camel route:

           

          <route errorHandlerRef="errorHandlerRef">
              <!-- ... -->
          </route>
          
          

           

           

          public class Factory {
              @Produces
              @Named("errorHandlerRef")
              public ErrorHandlerBuilder createErrorHandler() {
                  return new LoggingErrorHandlerBuilder();
              }
          }
          

           

          In Java DSL it's bit easier:

           

          public class Builder extends RouteBuilder {
              @Override
              public void configure() {
                  errorHandler(noErrorHandler());
                  from("...").to("...");
              }
          }
          
          • 2. Re: Question about errorHandler for switchyard.xml
            hisao.furuichi

            Thanks for your advice.  That's what I wanted to know!

            • 3. Re: Question about errorHandler for switchyard.xml
              hisao.furuichi

              I post a comment because I have a question relating with this thread.

              At first, I could set error handler options using CDI. Here is what I got so far.

               

              public class ErrorHandlerFactory {

                @Produces

                @Named("errorHandlerRef")

                public ErrorHandlerBuilder createErrorHandler() {

                            return new DefaultErrorHandlerBuilder().maximumRedeliveries(5).backOffMultiplier(2).retryAttemptedLogLevel(LoggingLevel.WARN);

                  }

              }

               

              Now, I'm thinking whether I can set options using xml-based configuration like <errorHandler>. Any idea?

               

              Thanks

              • 4. Re: Question about errorHandler for switchyard.xml
                splatch

                Camel service implementations limits camel usage only to one route so far. You may use all elements inside route definition which are supported by camel. The errorHandler element is available only under camelContext element, so you can not use it inside <route>, however you may configure all necessary settings with ErrorHandlerBuilder. Camel design in this area is really flatten - DefaultErrorHandler supports redelivery and dead letter. LoggingErrorHandler supports redelivery as well (it's extension of DefaultErrorHandler).

                 

                Kind regards,

                Lukasz

                • 5. Re: Question about errorHandler for switchyard.xml
                  hisao.furuichi

                  Thanks for your comment, and sorry for the late response.

                   

                  Now I understand that we can't use errorHandler element inside <route>. I found a jira ticket[1] talking about supporting <routes>, so I'm thinking there is a possibility to support <errorHandler> by supporting <routes>.  On the Jira, I added a comment for supporting <errorHandler>.  If you have a time, please check it.

                   

                  [1] Allow multiple route definitions per Camel service implementation

                  https://issues.jboss.org/browse/SWITCHYARD-1411#comment-12776193