public final class AdviceWith extends Object
Modifier and Type | Method and Description |
---|---|
static RouteDefinition |
adviceWith(org.apache.camel.CamelContext camelContext,
Object routeId,
boolean logXml,
org.apache.camel.util.function.ThrowingConsumer<AdviceWithRouteBuilder,Exception> builder)
Advices this route with the route builder using a lambda expression.
|
static RouteDefinition |
adviceWith(org.apache.camel.CamelContext camelContext,
Object routeId,
org.apache.camel.util.function.ThrowingConsumer<AdviceWithRouteBuilder,Exception> builder)
Advices this route with the route builder using a lambda expression.
|
static RouteDefinition |
adviceWith(RouteDefinition definition,
org.apache.camel.CamelContext camelContext,
RouteBuilder builder)
Advices this route with the route builder.
|
public static RouteDefinition adviceWith(org.apache.camel.CamelContext camelContext, Object routeId, org.apache.camel.util.function.ThrowingConsumer<AdviceWithRouteBuilder,Exception> builder) throws Exception
AdviceWith.adviceWith(context, "myRoute", a -> a.weaveAddLast().to("mock:result");Important: It is recommended to only advice a given route once (you can of course advice multiple routes). If you do it multiple times, then it may not work as expected, especially when any kind of error handling is involved. The advice process will add the interceptors, on exceptions, on completions etc. configured from the route builder to this route. This is mostly used for testing purpose to add interceptors and the likes to an existing route. Will stop and remove the old route from camel context and add and start this new advised route.
camelContext
- the camel contextrouteId
- either the route id as a string value, or null to chose the 1st route, or you can
specify a number for the n'th route, or provide the route definition instance directly as
well.builder
- the advice with route builderException
- can be thrown from the route builderpublic static RouteDefinition adviceWith(org.apache.camel.CamelContext camelContext, Object routeId, boolean logXml, org.apache.camel.util.function.ThrowingConsumer<AdviceWithRouteBuilder,Exception> builder) throws Exception
AdviceWith.adviceWith(context, "myRoute", false, a -> a.weaveAddLast().to("mock:result");Important: It is recommended to only advice a given route once (you can of course advice multiple routes). If you do it multiple times, then it may not work as expected, especially when any kind of error handling is involved. The advice process will add the interceptors, on exceptions, on completions etc. configured from the route builder to this route. This is mostly used for testing purpose to add interceptors and the likes to an existing route. Will stop and remove the old route from camel context and add and start this new advised route.
camelContext
- the camel contextrouteId
- either the route id as a string value, or null to chose the 1st route, or you can
specify a number for the n'th route, or provide the route definition instance directly as
well.logXml
- whether to log the before and after advices routes as XML to the log (this can be turned off
to perform faster)builder
- the advice with route builderException
- can be thrown from the route builderpublic static RouteDefinition adviceWith(RouteDefinition definition, org.apache.camel.CamelContext camelContext, RouteBuilder builder) throws Exception
RouteBuilder
but the specialized AdviceWithRouteBuilder
has additional
features when using the advice with feature. We therefore suggest you to use the AdviceWithRouteBuilder
.
The advice process will add the interceptors, on exceptions, on completions etc. configured from the route
builder to this route.
This is mostly used for testing purpose to add interceptors and the likes to an existing route.
Will stop and remove the old route from camel context and add and start this new advised route.definition
- the model definitioncamelContext
- the camel contextbuilder
- the route builderException
- can be thrown from the route builderAdviceWithRouteBuilder
Apache Camel