.handled(true) .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(400)) .setBody(constant("")); .handled(true) .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(404)) .setBody(constant("")); .handled(true) .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(500)) .setBody(simple("${exception.message}\n"));
@Override public void configure() throws Exception { restConfiguration() .component("servlet") .enableCORS(true) .contextPath("/") .bindingMode(RestBindingMode.auto); rest("/").get().produces("text/plain") .route().routeId("root") .to("http4:recommendation:8080/?httpClient.connectTimeout=1000&bridgeEndpoint=true©Headers=true&connectionClose=true") .routeId("recommendation") .onException(HttpOperationFailedException.class) .handled(true) .process(this::handleHttpFailure) .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(503)) .end() .onException(Exception.class) .handled(true) .transform(simpleF(RESPONSE_STRING_FORMAT, exceptionMessage()) ) .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(503)) .end() .transform(simpleF(RESPONSE_STRING_FORMAT, "${body}")) .endRest(); }
@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(); }
.handled(true) .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(400)) .setBody(constant("")); .handled(true) .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(404)) .setBody(constant("")); .handled(true) .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(500)) .setBody(simple("${exception.message}\n"));