pub struct RouteBuilder { /* private fields */ }Expand description
Implementations§
Source§impl RouteBuilder
impl RouteBuilder
Sourcepub fn filter<F>(self, predicate: F) -> FilterBuilder
pub fn filter<F>(self, predicate: F) -> FilterBuilder
Open a filter scope. Only exchanges matching predicate will be processed
by the steps inside the scope. Non-matching exchanges skip the scope entirely
and continue to steps after .end_filter().
Sourcepub fn choice(self) -> ChoiceBuilder
pub fn choice(self) -> ChoiceBuilder
Open a choice scope for content-based routing.
Within the choice, you can define multiple .when() clauses and an
optional .otherwise() clause. The first matching when predicate
determines which sub-pipeline executes.
Sourcepub fn wire_tap(self, endpoint: &str) -> Self
pub fn wire_tap(self, endpoint: &str) -> Self
Add a WireTap step that sends a clone of the exchange to the given endpoint URI (fire-and-forget). The original exchange continues downstream unchanged.
Sourcepub fn error_handler(self, config: ErrorHandlerConfig) -> Self
pub fn error_handler(self, config: ErrorHandlerConfig) -> Self
Set a per-route error handler. Overrides the global error handler on CamelContext.
Sourcepub fn circuit_breaker(self, config: CircuitBreakerConfig) -> Self
pub fn circuit_breaker(self, config: CircuitBreakerConfig) -> Self
Set a circuit breaker for this route.
Sourcepub fn concurrent(self, max: usize) -> Self
pub fn concurrent(self, max: usize) -> Self
Override the consumer’s default concurrency model.
When set, the pipeline spawns a task per exchange, processing them
concurrently. max limits the number of simultaneously active
pipeline executions (0 = unbounded, channel buffer is backpressure).
§Example
RouteBuilder::from("http://0.0.0.0:8080/api")
.concurrent(16) // max 16 in-flight pipeline executions
.process(handle_request)
.build()Sourcepub fn sequential(self) -> Self
pub fn sequential(self) -> Self
Force sequential processing, overriding a concurrent-capable consumer.
Useful for HTTP routes that mutate shared state and need ordering guarantees.
Sourcepub fn route_id(self, id: impl Into<String>) -> Self
pub fn route_id(self, id: impl Into<String>) -> Self
Set the route ID for this route.
If not set, the route will be assigned an auto-generated ID.
Sourcepub fn auto_startup(self, auto: bool) -> Self
pub fn auto_startup(self, auto: bool) -> Self
Set whether this route should automatically start when the context starts.
Default is true.
Sourcepub fn startup_order(self, order: i32) -> Self
pub fn startup_order(self, order: i32) -> Self
Set the startup order for this route.
Routes with lower values start first. Default is 1000.
Sourcepub fn split(self, config: SplitterConfig) -> SplitBuilder
pub fn split(self, config: SplitterConfig) -> SplitBuilder
Begin a Splitter sub-pipeline. Steps added after this call (until
.end_split()) will be executed per-fragment.
Returns a SplitBuilder — you cannot call .build() until
.end_split() closes the split scope (enforced by the type system).
Sourcepub fn multicast(self) -> MulticastBuilder
pub fn multicast(self) -> MulticastBuilder
Begin a Multicast sub-pipeline. Steps added after this call (until
.end_multicast()) will each receive a copy of the exchange.
Returns a MulticastBuilder — you cannot call .build() until
.end_multicast() closes the multicast scope (enforced by the type system).
Sourcepub fn throttle(self, max_requests: usize, period: Duration) -> ThrottleBuilder
pub fn throttle(self, max_requests: usize, period: Duration) -> ThrottleBuilder
Begin a Throttle sub-pipeline. Rate limits message processing to at most
max_requests per period. Steps inside the throttle scope are only
executed when the rate limit allows.
Returns a ThrottleBuilder — you cannot call .build() until
.end_throttle() closes the throttle scope (enforced by the type system).
Sourcepub fn load_balance(self) -> LoadBalancerBuilder
pub fn load_balance(self) -> LoadBalancerBuilder
Begin a LoadBalance sub-pipeline. Distributes exchanges across multiple endpoints using a configurable strategy (round-robin, random, weighted, failover).
Returns a LoadBalancerBuilder — you cannot call .build() until
.end_load_balance() closes the load balance scope (enforced by the type system).
Sourcepub fn dynamic_router(self, expression: RouterExpression) -> Self
pub fn dynamic_router(self, expression: RouterExpression) -> Self
Add a dynamic router step that routes exchanges dynamically based on expression evaluation at runtime.
The expression receives the exchange and returns Some(uri) to route to
the next endpoint, or None to stop routing.
§Example
RouteBuilder::from("timer:tick")
.route_id("test-route")
.dynamic_router(|ex| {
ex.input.header("dest").and_then(|v| v.as_str().map(|s| s.to_string()))
})
.build()Sourcepub fn dynamic_router_with_config(self, config: DynamicRouterConfig) -> Self
pub fn dynamic_router_with_config(self, config: DynamicRouterConfig) -> Self
Add a dynamic router step with full configuration.
Allows customization of URI delimiter, cache size, timeout, and other options.
Sourcepub fn build(self) -> Result<RouteDefinition, CamelError>
pub fn build(self) -> Result<RouteDefinition, CamelError>
Consume the builder and produce a RouteDefinition.
Sourcepub fn build_canonical(self) -> Result<CanonicalRouteSpec, CamelError>
pub fn build_canonical(self) -> Result<CanonicalRouteSpec, CamelError>
Compile this builder route into canonical v1 spec.