@Override public void configure() throws Exception { from("direct:input") // Enable the following statement if error handling // has been globally turned off via noErrorHandler(), // otherwise exception() statements have no effect. //.errorHandler(deadLetterChannel()) .onException(Exception1.class).to("mock:error1").end() .onException(Exception2.class).to("mock:error2").end() .onException(Exception.class).to("mock:error3").end() .process(exceptionProcessor()) .to("mock:success"); }
@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 { from("file://in").id("file2jms") .to("jms:person"); from("jms:person").id("personJms2Rest") // .onException(ConnectException.class).log("Exception processing message.. does the personservice run?").end() .setHeader("person_id", xpath("/person/id").stringResult()) .to("log:test") .setHeader(Exchange.HTTP_METHOD, constant("PUT")) .setHeader(Exchange.CONTENT_TYPE, constant("text/xml")) .setHeader(Exchange.HTTP_URI, simple("${properties:personServiceUri}/${header.person_id}")) // .to("http://dummy"); }
@Override public void configure() throws Exception { from("xds-iti41:continuaHRNService") .onException(Exception.class) .maximumRedeliveries(0) .end() .process(ContinuaHrnCamelProcessors.continuaHrnRequestTransformerAndValidator()) .process(CHECK_PROCESSOR) .setBody(constant(new Response(Status.SUCCESS))) .process(ContinuaHrnCamelProcessors.continuaHrnResponseValidator()); }
@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(); }
.onException(SmppException.class) .maximumRedeliveries(0) .end() .removeHeaders("CamelSmpp*")//In case it started as SMS elsewhere .process(origin)
@Override public void configure() throws Exception { // global error handler errorHandler(noErrorHandler()); from("direct:input-1") .to("mock:inter") // inherits global error handler (step in pipeline) .process(failure) // inherits global error handler (step in pipeline) .to("mock:output"); // inherits global error handler (step in pipeline) from("direct:input-2") // defines local error handler (placed before every node in this route) .errorHandler(defaultErrorHandler().maximumRedeliveries(2)).to("mock:error") .onException(Exception.class).handled(false).end() .to("mock:inter") // no redeliveries here .to("direct:temp"); // the error handler of this node redelivers from("direct:temp") .to("mock:check") // inherits global error handler (step in pipeline) .process(failure) // inherits global error handler (step in pipeline) .to("mock:output"); // inherits global error handler (step in pipeline) }