Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-6300

AdviceWith doesn't work with doTry

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.10.4
    • 2.10.5, 2.11.1, 2.12.0
    • tests
    • None
    • Java 6, macos

    • Unknown

    Description

      I have the following route definition:

              from("direct:billing_" + operation)
                      .routeId(getRouteId(operation))
                      .errorHandler(noErrorHandler()) // propagate exceptions to the parent route
      
                      .validate(body().isInstanceOf(
                              com.cleverlance.cleverbss.integration.modules.in.customer.model.Customer.class))
      
                      .beanRef(BILLING_CUSTOMER_ROUTE_BEAN, "createRequestFor" + WordUtils.capitalize(operation))
      
                       // SetCustomer -> XML
                      .marshal(jaxbIn)
      
                      .doTry()
                          .to(uri + "?messageSender=#billingSender").id("toURI")
                      .doCatch(AlreadyExistsException.class)
                          .setProperty(exPropertyName, property(Exchange.EXCEPTION_CAUGHT))
                      .end()
      
                      .choice()
                          .when(property(exPropertyName).isNull())
      
                          // XML -> SetCustomerResponse
                          .unmarshal(jaxbOut)
                      .endChoice();
      

      And I would like to replace TO in the tests:

              getCamelContext().getRouteDefinition(BillingCustomerRoutes.ROUTE_ID_UPDATE_CUSTOMER)
                      .adviceWith(getCamelContext(), new AdviceWithRouteBuilder() {
                          @Override
                          public void configure() throws Exception {                        
                              weaveByType(ToDefinition.class).replace().process(new Processor() {
                                  @Override
                                  public void process(Exchange exchange) throws Exception {
                                      throw new AlreadyExistsException("msg", new AlreadyExists());
                                  }
                              });
                          }
                      });
      

      When I use weaveById("toURI") or weaveByToString(), it doesn't work neither.

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            pjuza Petr Juza
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: