@Override public void configure() { from("direct:start") .id("start") .routePolicy(new ActivityTrackingPolicy(activityTracker)) .split() .body() .process(OutMessageCaptureProcessor.INSTANCE) .pipeline() .id("log") .log(LoggingLevel.INFO, "log", "log", "hi") .process(OutMessageCaptureProcessor.INSTANCE) .end() .pipeline() .id("rnderr") .process().body(String.class, body -> { if ("error".equals(body)) { throw new RuntimeException("Bean Error"); } }) .process(OutMessageCaptureProcessor.INSTANCE) .end() .pipeline() .id("end") .to("mock:end") .process(OutMessageCaptureProcessor.INSTANCE) .end() .end(); } });
@Override public void configure() throws Exception { restConfiguration() .component("servlet") .enableCORS(true) .contextPath("/") .bindingMode(RestBindingMode.auto); rest("/").get().consumes(MediaType.TEXT_PLAIN_VALUE) .route().routeId("root") .pipeline() .bean("CustomerCamelRoute", "addTracer") .to("http4:preference:8080/?httpClient.connectTimeout=1000&bridgeEndpoint=true©Headers=true&connectionClose=true") .end() .convertBodyTo(String.class) .onException(HttpOperationFailedException.class) .handled(true) .process(this::handleHttpFailure) .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(503)) .end() .onException(Exception.class) .log(exceptionMessage().toString()) .handled(true) .transform(simpleF(RESPONSE_STRING_FORMAT, exceptionMessage())) .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(503)) .end() .transform(simpleF(RESPONSE_STRING_FORMAT, "${body}")) .endRest(); }