Path: redb-route/redb.Route/Abstractions/IRouteDefinition.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route/Abstractions/IRouteDefinition.cs
----
using Json.Schema;
using Microsoft.Extensions.Logging;
using redb.Route.Definitions;
using redb.Route.Transactions;
using redb.Route.Validation;
using redb.Route.Xslt;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
namespace redb.Route.Abstractions;
///
/// New fluent DSL for defining a message route using the canonical ProcessorDefinition model.
/// All leaf methods return for chaining.
/// Scope-opener methods (Filter, Choice, Split, TryCatch, etc.) return the opened definition
/// and expose an End()/EndXxx() method that returns the parent definition.
///
public interface IRouteDefinition : IProcessorDefinition
{
// ── Identity ──
/// Assigns a unique route identifier.
IRouteDefinition RouteId(string routeId);
/// Gets the assigned route ID (null if not set).
string? GetRouteId();
///
/// Names the most recently added step (Apache Camel id() ), for AdviceWith weaving
/// (WeaveById ) and diagnostics. Before any step has been added it names the route itself.
///
IRouteDefinition Id(string id);
///
/// Gives the most recently added step a human-readable label (Apache Camel description() ).
/// The label replaces the type-derived one in message history; the node id is unaffected. Before
/// any step has been added it describes the route itself.
///
IRouteDefinition Description(string description);
// ── Interception and completion (declared on the route; RouteBuilder has the same verbs for every route) ──
/// Opens steps that run before every step of this route, including steps nested in scopes (Camel intercept() ). Close with EndIntercept() .
Definitions.InterceptDefinition Intercept();
/// Opens steps that run once when a message enters the route, optionally only for a From URI matching the mask (Camel interceptFrom() ).
Definitions.InterceptDefinition InterceptFrom(string? uriPattern = null);
/// Opens steps that run before a To / ToD whose target matches the mask; .SkipSendToOriginalEndpoint() replaces the send (Camel interceptSendToEndpoint() ).
Definitions.InterceptDefinition InterceptSendToEndpoint(string uriPattern);
/// Opens steps that run after the route finished with an exchange, on a copy, outside the route's transaction (Camel onCompletion() ). Close with EndOnCompletion() .
Definitions.OnCompletionDefinition OnCompletion();
// ── Header / property / body sugar ──
/// Sets several headers in one step; an or Func<IExchange, object?> value is evaluated per message, anything else is a constant.
IRouteDefinition SetHeaders(params (string Name, object? Value)[] headers);
/// Sets several exchange properties in one step, in order; an or Func<IExchange, object?> value is evaluated per message, anything else is a constant.
IRouteDefinition SetProperties(params (string Name, object? Value)[] properties);
/// Removes every header whose name matches the mask (exact, trailing * , or regex: ), except those listed.
IRouteDefinition RemoveHeaders(string pattern, params string[] except);
/// Removes every exchange property whose key matches the mask, except those listed.
IRouteDefinition RemoveProperties(string pattern, params string[] except);
/// Sorts the collection selected by a route-language expression and puts the sorted list into the body; the key expression sees each element as body (Sort("body.items", "body.priority") ).
IRouteDefinition Sort(string collectionExpression, string? keyExpression = null, bool descending = false);
/// Sorts a typed collection selected from the exchange; the body becomes a List<T> .
IRouteDefinition Sort(Func> source, Func? key = null, bool descending = false, IComparer? comparer = null);
/// Sets whether this route should auto-start. Default is true.
IRouteDefinition AutoStart(bool value = true);
/// Gets whether this route auto-starts.
bool GetAutoStart();
/// Sets the per-exchange processing timeout for this route.
/// Thrown when is zero or negative (excluding ).
IRouteDefinition ProcessingTimeout(TimeSpan timeout);
// ── Source ──
/// Sets the source (consumer) endpoint URI.
IRouteDefinition From(string uri);
/// Gets the source endpoint URI (null if not set).
string? GetFromUri();
// ── Destination ──
/// Sends the exchange to an endpoint via producer.
IRouteDefinition To(string uri);
/// Camel-style dynamic-to: sends the exchange to an endpoint URI computed
/// per message from a ${...} template (e.g. .ToD("kafka://orders-${header.region}") ).
/// Producers are cached per resolved URI and tracked by .
IRouteDefinition ToD(string uriTemplate);
/// Camel-style dynamic-to using an that yields the URI.
IRouteDefinition ToD(IExpression uriExpression);
/// Camel-style dynamic-to using a delegate that yields the URI per exchange.
IRouteDefinition ToD(Func uriFactory);
// ── Processing delegates ──
/// Processes the exchange with a synchronous action.
IRouteDefinition Process(Action action);
/// Processes the exchange with an asynchronous action.
IRouteDefinition Process(Func action);
/// Processes the exchange with a pre-built processor instance.
IRouteDefinition Process(IProcessor processor);
// ── Transform / body ──
/// Sets the exchange body to a static value.
IRouteDefinition SetBody(object? value);
/// Sets the exchange body using a factory.
IRouteDefinition SetBody(Func factory);
///
/// Sets the exchange body using an . A ${...} template is one:
/// SetBody(Expr("Hello ${header.name}")) . A plain string passed to
/// stays a literal — the position decides, the content never does.
///
IRouteDefinition SetBody(IExpression expression);
/// Transforms the exchange body using a factory.
IRouteDefinition Transform(Func transform);
/// Transforms the exchange body using an .
IRouteDefinition Transform(IExpression expression);
/// Removes (nulls) the exchange body.
IRouteDefinition RemoveBody();
// ── Headers ──
/// Sets a header to a static value.
IRouteDefinition SetHeader(string key, object? value);
/// Sets a header using a factory.
IRouteDefinition SetHeader(string key, Func factory);
///
/// Sets a header using an ; a ${...} template is one:
/// SetHeader("target", Expr("queue-${header.tenant}")) .
///
IRouteDefinition SetHeader(string name, IExpression expression);
/// Removes a header.
IRouteDefinition RemoveHeader(string key);
// ── Attachments ──
///
/// Adds an attachment to the message with the value of (byte[] , string as
/// UTF-8, a Stream , an ). The text arguments are literal.
///
IRouteDefinition AddAttachment(string name, IExpression content, string? fileName = null, string? contentType = null);
/// As with the file name evaluated per message.
IRouteDefinition AddAttachment(string name, IExpression content, IExpression fileName, string? contentType = null);
///
/// Adds the message body as an attachment; the body stays. The content type defaults to the message's. The text
/// arguments are literal.
///
IRouteDefinition AddAttachmentFromBody(string name, string? fileName = null, string? contentType = null);
/// As with the file name evaluated per message.
IRouteDefinition AddAttachmentFromBody(string name, IExpression fileName, string? contentType = null);
///
/// Adds the file at as an attachment, read from disk whenever it is sent; the name and file
/// name default to the file's name. The text arguments are literal.
///
IRouteDefinition AddAttachmentFromFile(string path, string? name = null, string? contentType = null);
/// As with the path evaluated per message.
IRouteDefinition AddAttachmentFromFile(IExpression path, string? name = null, string? contentType = null);
/// Removes the attachments named .
IRouteDefinition RemoveAttachment(string name);
/// Removes every attachment of the message.
IRouteDefinition RemoveAttachments();
// ── Properties ──
/// Sets a property to a static value.
IRouteDefinition SetProperty(string key, object? value);
/// Sets a property using a factory.
IRouteDefinition SetProperty(string key, Func factory);
///
/// Sets a property using an ; a ${...} template is one:
/// SetProperty("tenant", Expr("${header.tenant}")) .
///
IRouteDefinition SetProperty(string key, IExpression expression);
/// Removes a property.
IRouteDefinition RemoveProperty(string key);
// ── Logging ──
/// Logs a static message.
IRouteDefinition Log(string message, LogLevel level = LogLevel.Information);
/// Logs a dynamic message from a factory.
IRouteDefinition Log(Func messageFactory, LogLevel level = LogLevel.Information);
// ── Stop / Throw ──
/// Stops exchange processing.
IRouteDefinition Stop();
/// Rethrows the exception stored on the exchange.
IRouteDefinition ThrowException();
/// Throws a new exception with the given message.
IRouteDefinition ThrowException(string message);
/// Throws a specific pre-built exception instance.
IRouteDefinition ThrowException(Exception exception);
/// Instantiates and throws an exception by type and message.
IRouteDefinition ThrowException(Type exceptionType, string message);
/// Instantiates and throws a typed exception.
IRouteDefinition ThrowException(string? message = null) where TException : Exception, new();
// ── Delay / Sampling ──
/// Delays processing by a fixed duration.
IRouteDefinition Delay(TimeSpan duration);
/// Delays processing by a dynamic duration computed from the exchange.
IRouteDefinition Delay(Func factory);
/// Delays by a route-language expression evaluated per message: milliseconds ("${header.backoff}" , "header.attempt * 500" ), a , or hh:mm:ss text.
IRouteDefinition Delay(string durationExpression);
/// Samples messages by passing every N-th message (count-based).
IRouteDefinition Sample(long messageFrequency);
/// Samples messages by period — at most one message per .
IRouteDefinition Sample(TimeSpan period);
// ── Stream caching ──
///
/// Wraps a forward-only body with a seekable cache so
/// subsequent steps can re-read it multiple times. Non-Stream bodies pass through unchanged.
///
/// Bytes threshold before spooling to a temp file (null = default 128 KB).
IRouteDefinition StreamCaching(long? spoolThreshold = null);
// ── Validation ──
/// Validates the exchange using the provided instance.
IRouteDefinition Validate(IMessageValidator validator, bool throwOnFailure = true);
/// Validates the exchange using a predicate function.
IRouteDefinition Validate(Func predicate, string errorMessage = "Validation failed", bool throwOnFailure = true);
/// Validates the exchange against an .
IRouteDefinition Validate(IPredicate predicate, string errorMessage = "Validation failed", bool throwOnFailure = true);
///
/// Validates the exchange against an expression read as a condition, as Filter and When read one:
/// Validate(Expr("header.amount > 0")) , Validate(Method("#rules", "IsValid(${body})")) , where a
/// Task<bool> method is awaited.
///
IRouteDefinition Validate(IExpression condition, string errorMessage = "Validation failed", bool throwOnFailure = true)
=> Validate(Predicates.PredicateFactory.FromExpression(condition), errorMessage, throwOnFailure);
/// Validates the exchange body against a JSON Schema provided as a string.
IRouteDefinition ValidateJsonSchema(string schemaJson, bool throwOnFailure = true);
/// Validates the exchange body against a pre-parsed .
IRouteDefinition ValidateJsonSchema(JsonSchema schema, bool throwOnFailure = true);
/// Validates the exchange body against an XSD schema string.
IRouteDefinition ValidateXsd(string xsdContent, bool throwOnFailure = true);
/// Validates the exchange body against an XSD schema string with an explicit target namespace.
IRouteDefinition ValidateXsd(string? targetNamespace, string xsdContent, bool throwOnFailure = true);
/// Validates the exchange body against a pre-built .
IRouteDefinition ValidateXsd(XmlSchemaSet schemaSet, bool throwOnFailure = true);
///
/// Validates the exchange body against an XSD file whose xs:import and xs:include are read relative
/// to it, from under only (never the network); a reference that does not load is an
/// error when the route is built. The path resolves through the context's resource resolver.
///
/// The XSD file (schemas/order.xsd ).
/// Target namespace; null takes the schema's own.
///
/// The directory imports stay under, relative to the schema's directory; null is that directory.
///
/// Whether a validation failure throws.
IRouteDefinition ValidateXsdFile(string schemaPath, string? targetNamespace = null, string? schemaRoot = null,
bool throwOnFailure = true);
// ── XSLT ──
/// Apache Camel xslt: parity: transform the body through an XSLT stylesheet file.
IRouteDefinition Xslt(string stylesheetPath, XsltOutput output = XsltOutput.String, bool failOnNullBody = true, bool allowTemplateFromHeader = false);
/// Transform the body through an inline XSLT stylesheet document.
IRouteDefinition XsltContent(string stylesheetXml, XsltOutput output = XsltOutput.String, bool failOnNullBody = true, bool allowTemplateFromHeader = false);
// ── Control Bus ──
/// Apache Camel controlbus: parity: manage a route at runtime (start/stop/suspend/resume/restart/status/stats/fail).
IRouteDefinition ControlBus(redb.Route.ControlBus.ControlBusAction action, string routeId, bool async = false);
// ── Serialization ──
/// Marshals (serializes) the exchange body using the specified serializer type.
IRouteDefinition Marshal(Type serializerType);
/// Marshals (serializes) the exchange body using the specified serializer type.
IRouteDefinition Marshal() where TSerializer : class;
/// Unmarshals (deserializes) the exchange body to using the specified serializer type.
IRouteDefinition Unmarshal(Type serializerType, Type targetType);
/// Unmarshals (deserializes) the exchange body using the specified serializer and target types.
IRouteDefinition Unmarshal() where TSerializer : class;
/// Marshals the body with the data format registered for ("text/csv" ); an unregistered format fails Start() .
IRouteDefinition Marshal(string contentType);
/// Marshals the body with a configured serializer instance (per-node options): Marshal(new CsvDataFormat(o)) .
IRouteDefinition Marshal(IMessageSerializer serializer);
/// Unmarshals the body to with the data format registered for .
IRouteDefinition Unmarshal(string contentType);
/// Unmarshals the body to with the data format registered for .
IRouteDefinition Unmarshal(string contentType, Type targetType);
/// Unmarshals the body to with a configured serializer instance.
IRouteDefinition Unmarshal(IMessageSerializer serializer);
/// Unmarshals the body to with a configured serializer instance.
IRouteDefinition Unmarshal(IMessageSerializer serializer, Type targetType);
/// Apache Camel parity: unmarshal the body to using the data format
/// registry entry resolved from the incoming message ContentType.
IRouteDefinition Unmarshal();
/// Apache Camel parity: convert the exchange body to .
IRouteDefinition ConvertBody();
/// Apache Camel parity: convert the exchange body to .
IRouteDefinition ConvertBody(Type targetType);
/// Apache Camel parity: open a typed scope auto-converting the body to .
OfTypeDefinition OfType();
// ── Transactions ──
/// Begins an imperative transaction scope on the exchange (default Required policy).
IRouteDefinition BeginTransaction();
/// Begins an imperative transaction scope with the specified .
IRouteDefinition BeginTransaction(TransactionPolicy policy);
/// Commits the imperative transaction scope and all deferred actions.
IRouteDefinition CommitTransaction();
/// Rolls back the imperative transaction scope and all deferred actions.
IRouteDefinition RollbackTransaction();
///
/// Opens a declarative transaction scope. All child steps execute inside a
/// TransactedProcessor that auto-commits on success and auto-rolls-back on failure.
/// Close the scope with or
/// the universal .
///
Definitions.TransactionDefinition Transaction(TransactionPolicy? policy = null);
// ── Replay checkpoints ──
///
/// Opens a replay checkpoint (save-point). The steps that follow are the marker's body (the tail
/// re-run on replay); the exchange is snapshotted into route.checkpoint on each pass. At
/// the start of a route no End is needed; otherwise close with
/// or use the lambda-body overload.
///
Definitions.ReplayableDefinition Replayable(string name, bool exposed = false);
/// Lambda-body form of ; the chain stays on the current definition.
IRouteDefinition Replayable(string name, Action body, bool exposed = false);
// ── Telemetry ──
///
/// Opens a tracing scope. All child steps run inside a single Activity span named .
/// Close with or .
///
Definitions.TracedDefinition Traced(string operationName);
///
/// Inline tracing — wraps a single synchronous action in an Activity span named .
///
IRouteDefinition Traced(string operationName, Action action);
///
/// Inline tracing — wraps an asynchronous action in an Activity span named .
///
IRouteDefinition Traced(string operationName, Func action);
///
/// Inline tracing — wraps an in an Activity span named .
///
IRouteDefinition Traced(string operationName, IProcessor processor);
///
/// Opens a metrics scope. All child steps are measured by MeteredStepProcessor
/// tagged with .
/// Close with or .
///
Definitions.MeteredDefinition Metered(string stepName);
///
/// Inline metering — wraps a single synchronous action in a MeteredStepProcessor tagged with .
///
IRouteDefinition Metered(string stepName, Action action);
///
/// Inline metering — wraps an asynchronous action in a MeteredStepProcessor tagged with .
///
IRouteDefinition Metered(string stepName, Func action);
///
/// Inline metering — wraps an in a MeteredStepProcessor tagged with .
///
IRouteDefinition Metered(string stepName, IProcessor processor);
///
/// Puts the attribute = (a literal) on a span of the engine, so the
/// trace can be found by it. See .
///
/// Attribute name: lowercase, dot-separated, outside the reserved namespaces (redb. , http. , ...).
/// The value, as is — a literal, never a template; a template is Expr("${...}") .
/// Which span receives it; the enclosing Traced scope or route span by default.
IRouteDefinition SpanTag(string key, string value, Telemetry.SpanTarget target = Telemetry.SpanTarget.Enclosing);
///
/// Puts the attribute on a span of the engine, its value evaluated per message — the way to
/// find a trace by a business key (.SpanTag("sap.order.id", XPath("/Ack/OrderNo")) ). The exchange is not
/// touched. Nothing is set without a listener, on an unsampled span (the value is then not evaluated), for a
/// null or empty value, or when the value fails to evaluate (logged at Debug). The value is exported
/// unfiltered: never personal data or credentials. Its length is limited by the OpenTelemetry SDK
/// (OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT ).
///
/// Attribute name: lowercase, dot-separated, outside the reserved namespaces (redb. , http. , ...).
/// Expression producing the value.
/// Which span receives it; the enclosing Traced scope or route span by default.
/// is templated, malformed, reserved or names a secret.
IRouteDefinition SpanTag(string key, IExpression value, Telemetry.SpanTarget target = Telemetry.SpanTarget.Enclosing);
// ── Enrichment ──
///
/// Sends a copy of the exchange to a URI and continues (wire tap). The copy runs on the tap's own bounded pool;
/// when the pool and its queue are full, the profile's rejected policy decides (by default the caller runs it).
///
/// The thread pool profile the tap builds its own pool from (Camel executorService ); the context's default profile when null . An unknown name fails when the route is built.
IRouteDefinition WireTap(string uri, string? executorService = null);
/// Sends a wire-tap copy to a URI, calling on the clone before dispatching.
/// The thread pool profile the tap builds its own pool from (Camel executorService ); the context's default profile when null . An unknown name fails when the route is built.
IRouteDefinition WireTap(string uri, Action onPrepare, string? executorService = null);
/// Sends a wire-tap copy to a URI, replacing the clone's body with the result of .
/// The thread pool profile the tap builds its own pool from (Camel executorService ); the context's default profile when null . An unknown name fails when the route is built.
IRouteDefinition WireTap(string uri, Func newBodyFactory, string? executorService = null);
/// Sends a wire-tap copy to a URI with both an callback and a body replacement factory.
/// The thread pool profile the tap builds its own pool from (Camel executorService ); the context's default profile when null . An unknown name fails when the route is built.
IRouteDefinition WireTap(string uri, Action onPrepare, Func newBodyFactory, string? executorService = null);
/// Wire-tap to a dynamic URI computed per message from a factory.
/// Producers are cached per resolved URI.
/// The thread pool profile the tap builds its own pool from (Camel executorService ); the context's default profile when null . An unknown name fails when the route is built.
IRouteDefinition WireTap(Func uriFactory, string? executorService = null);
/// Dynamic-URI wire-tap with an callback.
/// The thread pool profile the tap builds its own pool from (Camel executorService ); the context's default profile when null . An unknown name fails when the route is built.
IRouteDefinition WireTap(Func uriFactory, Action onPrepare, string? executorService = null);
/// Dynamic-URI wire-tap with a body replacement factory.
/// The thread pool profile the tap builds its own pool from (Camel executorService ); the context's default profile when null . An unknown name fails when the route is built.
IRouteDefinition WireTap(Func uriFactory, Func newBodyFactory, string? executorService = null);
/// Dynamic-URI wire-tap with both an callback and a body factory.
/// The thread pool profile the tap builds its own pool from (Camel executorService ); the context's default profile when null . An unknown name fails when the route is built.
IRouteDefinition WireTap(Func uriFactory, Action onPrepare, Func newBodyFactory, string? executorService = null);
/// Content enricher — calls an endpoint and merges the result.
IRouteDefinition Enrich(string resourceUri, Func mergeStrategy);
/// Content enricher with a dynamic endpoint URI computed per message.
IRouteDefinition Enrich(Func uriFactory, Func mergeStrategy);
/// Content enricher whose endpoint URI comes from an expression, e.g. Enrich(XPath("/order/service"), merge) .
IRouteDefinition Enrich(IExpression uri, Func mergeStrategy);
/// Content enricher from an expression, keeping the enriched result (UseLatest ).
IRouteDefinition Enrich(IExpression uri);
/// Apache Camel parity: poll an external endpoint and merge the polled result.
IRouteDefinition PollEnrich(
string resourceUri,
Func mergeStrategy,
TimeSpan? timeout = null);
/// Poll enricher with a dynamic endpoint URI computed per message.
IRouteDefinition PollEnrich(
Func uriFactory,
Func mergeStrategy,
TimeSpan? timeout = null);
/// Enrich without a strategy: the response becomes the current message (Camel default, AggregationStrategies.UseLatest() ).
IRouteDefinition Enrich(string resourceUri);
/// Enrich with a dynamic URI and no strategy: the response becomes the current message.
IRouteDefinition Enrich(Func uriFactory);
/// Poll enricher without a strategy: the polled message becomes the current one; on timeout the original stays.
IRouteDefinition PollEnrich(string resourceUri, TimeSpan? timeout = null);
/// Poll enricher with a dynamic URI and no strategy: the polled message becomes the current one; on timeout the original stays.
IRouteDefinition PollEnrich(Func uriFactory, TimeSpan? timeout = null);
/// Poll enricher whose endpoint URI comes from an expression.
IRouteDefinition PollEnrich(
IExpression uri,
Func mergeStrategy,
TimeSpan? timeout = null);
/// Poll enricher from an expression with no strategy: the polled message becomes the current one.
IRouteDefinition PollEnrich(IExpression uri, TimeSpan? timeout = null);
/// Apache Camel parity: route to a list of recipient URIs computed at runtime.
IRouteDefinition RecipientList(
Func> recipientListFactory,
bool parallelProcessing = false,
bool stopOnException = false,
Func? aggregationStrategy = null);
///
/// Recipient list from an expression yielding either a sequence of URIs or one delimited
/// string, e.g. RecipientList(XPath("/order/recipients/uri")) .
///
IRouteDefinition RecipientList(
IExpression recipients,
bool parallelProcessing = false,
bool stopOnException = false,
Func? aggregationStrategy = null,
string uriDelimiter = ",");
/// Apache Camel parity: iteratively route to URIs returned by a routing function.
IRouteDefinition DynamicRouter(Func routingFunction);
/// Dynamic router whose next hop comes from an expression; no value ends the routing.
IRouteDefinition DynamicRouter(IExpression routingExpression);
/// Apache Camel parity: Routing Slip — pipe the exchange through a list of endpoints
/// computed once up front (Out→In between hops).
IRouteDefinition RoutingSlip(Func> slipFactory, bool ignoreInvalidEndpoints = false);
/// Apache Camel parity: Routing Slip from an expression yielding a delimited URI string.
IRouteDefinition RoutingSlip(IExpression slip, string uriDelimiter = ",", bool ignoreInvalidEndpoints = false);
/// Apache Camel parity: Routing Slip from a ${...} template resolving to a delimited URI string.
IRouteDefinition RoutingSlip(string slipTemplate, string uriDelimiter = ",", bool ignoreInvalidEndpoints = false);
/// Apache Camel parity: open a Resequencer scope. Child outputs receive exchanges
/// in the order determined by .
ResequenceDefinition Resequence(
Func keySelector,
int batchSize = 100,
TimeSpan? timeout = null);
// ── Scope openers ──
///
/// Opens a Filter scope. Only exchanges matching the predicate will be processed by steps
/// inside the scope. Close with .
///
FilterDefinition Filter(Func predicate);
///
/// Opens a Filter scope using an predicate.
/// Close with .
///
FilterDefinition Filter(IExpression expression);
///
/// Opens a Filter scope guarded by an . The predicate is stored as the
/// filter's condition and awaited per message through .
///
FilterDefinition Filter(IPredicate predicate);
///
/// Opens an Idempotent Consumer scope. Duplicate exchanges (same key) are skipped.
/// Close with .
///
IdempotentConsumerDefinition IdempotentConsumer(
IIdempotentRepository repository,
Func keyExtractor,
bool skipDuplicate = true);
///
/// Opens an Idempotent Consumer scope with the repository looked up by registered name at
/// compile time — available on every definition, so the scope nests like any other.
///
IdempotentConsumerDefinition IdempotentConsumer(
Func keyExtractor,
string repositoryName,
bool skipDuplicate = true);
/// Idempotent Consumer whose message id comes from an expression, e.g. IdempotentConsumer(repo, jpath("$.messageId")) .
IdempotentConsumerDefinition IdempotentConsumer(
IIdempotentRepository repository,
IExpression messageId,
bool skipDuplicate = true);
/// Idempotent Consumer from an expression, with the repository looked up by registered name.
IdempotentConsumerDefinition IdempotentConsumer(
IExpression messageId,
string repositoryName,
bool skipDuplicate = true);
///
/// Claim Check step (Hohpe/Woolf). Stores the body away and lets a short claim key travel
/// the route in its place, or restores the body from such a key.
///
///
/// / /
/// address an explicit key;
/// / use an
/// exchange-scoped stack and need none.
///
/// Explicit claim key for Set/Get/GetAndRemove. Ignored by Push/Pop.
/// Time-to-live for stored data. Used by Set/Push.
///
/// Logical name of a repository registered with
/// context.AddClaimCheckRepository(name, repository) . Null uses the context default.
///
IRouteDefinition ClaimCheck(
ClaimCheckOperation operation,
string? key = null,
TimeSpan? ttl = null,
string? repositoryName = null);
///
/// Claim Check step against an explicit repository instance.
///
IRouteDefinition ClaimCheck(
IClaimCheckRepository repository,
ClaimCheckOperation operation,
string? key = null,
TimeSpan? ttl = null);
///
/// Opens a Choice (content-based router) scope.
/// Add branches with .When() / .Otherwise() , close with .EndChoice() .
///
ChoiceDefinition Choice();
///
/// Opens a Split scope. The splitter function splits the exchange body into parts;
/// each part is processed through the scope pipeline.
/// Close with .
///
SplitDefinition Split(Func> splitter);
///
/// Opens a Split scope using an expression to produce the split parts.
/// The expression must evaluate to .
/// Close with .
///
SplitDefinition Split(IExpression expression);
///
/// Opens a streaming Split scope backed by an async enumerable (no parallel / aggregation).
/// Parts are processed one at a time without buffering. One part is read ahead, as Apache Camel's streaming split
/// asks its iterator: whether a part is the last one (CamelSplitComplete ) is known only once the next read
/// finds nothing. A part must therefore stay valid after the next one is read: yield a value, not a view into a
/// buffer the next read reuses.
/// Close with .
///
SplitDefinition Split(Func> splitter);
///
/// Opens a Multicast scope (fan-out). Add targets with .To() / .Process() .
/// Close with .
///
MulticastDefinition Multicast();
///
/// Opens a Threads scope (Camel-style concurrency handoff). The child pipeline runs on a bounded
/// pool of persistent workers, so a serial polling consumer can process
/// up to exchanges concurrently. Async boundary — does not extend the
/// caller's transaction; ordering is not preserved when > 1.
/// Close with .
///
/// Number of concurrent workers (must be >= 1).
ThreadsDefinition Threads(int poolSize);
///
/// Opens a TryCatch scope. Build the try body with leaf methods,
/// then open catch branches with .Catch<T>() and optionally .Finally() .
/// Close with .EndTryCatch() .
///
TryCatchDefinition TryCatch();
///
/// Opens an Aggregate scope. Collects exchanges by correlation key and forwards completed
/// aggregates to the body pipeline. Close with .EndAggregate() .
///
AggregateDefinition Aggregate(
Func correlationKey,
Func aggregationStrategy,
Func completionPredicate);
///
/// Opens an Aggregate scope whose correlation key comes from an expression, e.g.
/// Aggregate(XPath("/order/customerId"), strategy, completion) .
///
AggregateDefinition Aggregate(
IExpression correlationKey,
Func aggregationStrategy,
Func completionPredicate);
///
/// Opens a Throttle scope that limits exchange throughput to
/// per period. Close with .EndThrottle() .
///
ThrottleDefinition Throttle(int maxPerPeriod);
///
/// Opens a Throttle scope whose limit is computed per exchange: the factory runs on every
/// message, so the limit can come from a header, a property or an expression and change
/// between messages. Close with .EndThrottle() .
///
ThrottleDefinition Throttle(Func maxPerPeriodFactory);
/// Throttle whose per-period limit is a route-language expression evaluated per message ("${header.rate}" , "header.tier == 'gold' ? 100 : 10" ).
ThrottleDefinition Throttle(string maxPerPeriodExpression, TimeSpan? period = null);
///
/// Opens a keyed Throttle scope that limits throughput per unique key extracted from the exchange.
/// Close with .EndKeyedThrottle() .
///
KeyedThrottleDefinition Throttle(
Func keyExtractor,
int maxPerPeriod,
TimeSpan? period = null);
///
/// Keyed Throttle whose limit is read from each message as well as its key: "gold customers 100
/// per second, others 10, each under its own key". Close with .EndKeyedThrottle() .
///
KeyedThrottleDefinition Throttle(
Func keyExtractor,
Func maxPerPeriodFactory,
TimeSpan? period = null);
///
/// Keyed Throttle from two route-language expressions: the key ("header.customerId" ) and the
/// per-message limit ("header.tier == 'gold' ? 100 : 10" ). Both compile at build.
///
KeyedThrottleDefinition Throttle(
string keyExpression,
string maxPerPeriodExpression,
TimeSpan? period = null);
///
/// Opens a CircuitBreaker scope. Configure options before adding downstream steps.
/// Optionally add a fallback with .OnFallback() .
/// Close with .EndCircuitBreaker() .
///
CircuitBreakerDefinition CircuitBreaker();
///
/// Opens a Debounce scope. Suppresses rapid-fire messages per key, forwarding only the last
/// exchange after of silence. Close with .EndDebounce() .
///
DebounceDefinition Debounce(Func keyExtractor, TimeSpan quietPeriod);
///
/// Opens a Loop scope that repeats the body pipeline times.
/// Close with .
///
/// Fixed number of iterations (non-negative).
/// If true each iteration receives a clone of the original exchange.
/// If true (default) clone iterations share the parent DI scope.
LoopDefinition Loop(int count, bool copy = false, bool shareScope = true);
///
/// Opens a Loop scope that repeats the body pipeline while holds.
/// Close with .
///
LoopDefinition Loop(Func condition, bool copy = false, bool shareScope = true);
///
/// Opens a Loop scope that repeats while an holds; the predicate is
/// awaited before every iteration.
///
LoopDefinition Loop(IPredicate condition, bool copy = false, bool shareScope = true);
///
/// Opens a Loop scope that repeats the body pipeline a number of times resolved from the exchange at runtime.
/// Close with .
///
LoopDefinition Loop(Func countFactory, bool copy = false, bool shareScope = true);
/// Loop whose iteration count is a route-language expression evaluated per message ("${header.count}" , "header.items.Count" ); for a condition use LoopWhile(string) .
LoopDefinition Loop(string countExpression, bool copy = false, bool shareScope = true);
// ── Bean / Service Activator ──
/// Resolves from the exchange's ServiceProvider and invokes .
IRouteDefinition Bean(Func method);
/// Resolves from the exchange's ServiceProvider and invokes (no cancellation token).
IRouteDefinition Bean(Func method);
/// Resolves from the exchange's ServiceProvider and invokes a synchronous .
IRouteDefinition Bean(Action method);
///
/// Apache Camel's bean(ref, method) : calls user code through the bean: component, as the step
/// To("bean:" + reference + "?method=" + method) does, with the same endpoint, cache entry and statistics.
///
///
/// #name for an object in the context registry, or Namespace.Type, Assembly for an instance the
/// endpoint creates.
///
///
/// The method in the bean: URI spelling: a name (Handle ) or a name with bound arguments
/// (Gross(${header.qty}, ${header.price}) ). Null picks the single suitable method.
///
IRouteDefinition Bean(string reference, string? method = null)
=> To(Components.Bean.BeanComponent.UriFor(reference, method));
// ── Scatter-Gather ──
///
/// Adds a scatter-gather step with static recipients and the specified aggregation strategy.
///
IRouteDefinition ScatterGather(
Func aggregationStrategy,
params string[] recipients);
///
/// Adds a scatter-gather step configured via a builder callback.
///
IRouteDefinition ScatterGather(Action configure);
// ── Saga ──
///
/// Adds a saga step configured via a builder callback.
///
IRouteDefinition Saga(Action configure);
///
/// Opens a saga scope. Add steps with SagaStep() / OnSagaCompletion() ,
/// then close with or
/// .
///
Definitions.SagaDefinition Saga();
// ── LoadBalance ──
///
/// Adds a load-balance step with the specified strategy and endpoint URIs.
///
IRouteDefinition LoadBalance(ILoadBalancerStrategy strategy, params string[] uris);
///
/// Adds a load-balance step configured via a builder callback.
///
IRouteDefinition LoadBalance(Action configure);
// ── Normalizer ──
///
/// Adds a normalizer step configured via a builder callback.
/// Each when-clause transforms messages matching its predicate.
///
IRouteDefinition Normalize(Action configure);
// ── Exception handling ──
/// Marks the exchange exception as handled: clears the exception and sets ExceptionHandled = true .
IRouteDefinition ExceptionHandled();
///
/// Camel's markRollbackOnly() : marks the unit of work for rollback (the RollbackOnly property), rolls
/// back the deferred sends and stops the route. The enclosing transaction rolls the database back without an
/// exception, and the consumer does not acknowledge the message, so the broker delivers it again.
///
IRouteDefinition RollbackAll();
///
/// Opens an OnException scope for .
/// Configure redelivery/handling, then close with .EndOnException() or .End() .
/// The child steps (added before closing) form the body to protect.
///
Definitions.OnExceptionDefinition OnException() where TException : Exception;
///
/// Opens an OnException scope for multiple exception types.
/// Configure redelivery/handling, then close with .EndOnException() or .End() .
/// The child steps (added before closing) form the body to protect.
///
/// Thrown when is empty or contains a non-Exception type.
Definitions.OnExceptionDefinition OnException(params Type[] exceptionTypes);
// ── Route-level policy ──
/// Sets whether this route participates in cluster-aware routing. Default: false.
IRouteDefinition Cluster(bool value = true);
/// Gets whether this route participates in cluster-aware routing.
bool GetCluster();
/// Apache Camel parity: enable/disable per-node message history for this route, overriding
/// the global RouteEngineOptions.EnableMessageHistory .
IRouteDefinition MessageHistory(bool value = true);
/// Gets the route-level message-history override (null = inherit the global setting).
bool? GetMessageHistory();
/// Apache Camel parity: enable/disable OpenTelemetry tracing for this route, overriding
/// the global RouteEngineOptions.EnableTelemetry . Pass false for a service route
/// (a health check, a metric summary on a timer) whose single-span traces only crowd the collector.
IRouteDefinition Tracing(bool value = true);
/// Gets the route-level tracing override (null = inherit the global setting).
bool? GetTracing();
/// Sets an explicit route policy, overriding any factory-resolved policy.
IRouteDefinition RoutePolicy(IRoutePolicy policy);
///
/// Attaches a route policy by its registry name: the instance is resolved
/// from when the route compiles, and a missing
/// registration fails Start() naming the route. A leading # is accepted.
///
IRouteDefinition RoutePolicy(string policyName);
/// Registry name set by , null when unset.
string? GetRoutePolicyName();
/// Gets the explicitly set route policy, or null if not set.
IRoutePolicy? GetRoutePolicy();
///
/// Assigns route configurations to the route by id (Apache Camel's routeConfigurationId ): several ids
/// separated by commas, each an exact id, a wildcard ending in * or a regular expression. A route with
/// assigned configurations does not get the nameless ones — those are the default for routes without an assignment.
/// An exact id no configuration of the context has fails Start() , naming the route.
///
IRouteDefinition RouteConfigurationId(string ids);
/// The ids set by , null when unset.
string? GetRouteConfigurationId();
// ── Rich logging scope ──
///
/// Opens a rich-log scope at .
/// Shorthand for : add messages/headers/properties, then
/// close with .EndLog() or .End() .
///
Definitions.RichLogScopeDefinition Log();
///
/// Opens a rich-log scope at the given .
/// Add messages/headers/properties, then close with .EndLog() or .End() .
///
Definitions.RichLogScopeDefinition Log(LogLevel level);
}