Interface IRouteContext
Central runtime context for route management: endpoint cache, component registry,
named object registry, context-level properties, service locator, and route lifecycle.
Provides three-tier exception handling (local route → global → error handler fallback).
Thread-safe via .
public interface IRouteContext : IDisposable
Properties
ErrorHandler
Gets or sets the context's error handler — Apache Camel's context-level error handler: on every route, the
IErrorHandler? ErrorHandler { get; set; }
Routes
Returns a snapshot of all compiled routes managed by this context.
IReadOnlyList<CompiledRoute> Routes { get; }
this[string]
Gets or sets a context-level property by key. Returns null if not found.
object? this[string key] { get; set; }
Methods
AddComponent(IComponent)
Registers a component for its URI scheme.
void AddComponent(IComponent component)
AddGlobalExceptionHandler(Type, IProcessor)
Registers a global exception handler for the specified exception type (non-generic overload).
void AddGlobalExceptionHandler(Type exceptionType, IProcessor processor)
AddGlobalExceptionHandler<TException>(IProcessor)
Registers a global exception handler for a specific exception type: on every route, for a failure of this type
void AddGlobalExceptionHandler<TException>(IProcessor processor) where TException : Exception
AddLifecycleListener(IRouteLifecycleListener)
Registers a lifecycle listener for route and context state change notifications.
IRouteContext AddLifecycleListener(IRouteLifecycleListener listener)
AddLocalExceptionHandler(string, Type, IProcessor)
Registers a local exception handler for a specific route and exception type: checked before the global
void AddLocalExceptionHandler(string routeId, Type exceptionType, IProcessor processor)
AddRoutePolicyFactory(IRoutePolicyFactory)
Registers a factory that can create instances for routes
IRouteContext AddRoutePolicyFactory(IRoutePolicyFactory factory)
AddService(Type, object)
Registers a service instance by type.
void AddService(Type serviceType, object service)
AddThreadPoolProfile(string, ThreadPoolProfile)
Registers a named thread pool profile that a detached step (WireTap, asynchronous OnCompletion)
void AddThreadPoolProfile(string name, ThreadPoolProfile profile)
AddToRegistry(string, object)
Stores a named object in the registry (factories, shared state, etc.).
IRouteContext AddToRegistry(string key, object value)
GetComponent<T>(string?)
Gets a component by type, optionally filtering by scheme name.
T? GetComponent<T>(string? scheme = null) where T : class, IComponent
GetComponentNames()
Returns a snapshot of all registered component scheme names.
IReadOnlyList<string> GetComponentNames()
GetEndpoint(string)
Resolves or creates an endpoint by URI string. Caches by NormalizedKey.
IEndpoint GetEndpoint(string uri)
GetEndpoints()
Returns a snapshot of all currently cached endpoints.
IReadOnlyList<IEndpoint> GetEndpoints()
GetFromRegistry<T>(string)
Retrieves a typed object from the registry.
T? GetFromRegistry<T>(string key)
GetProperty<T>(string)
Gets a typed property value with automatic conversion.
T? GetProperty<T>(string key)
GetReplayMarkers()
Lists every compiled replay marker as (routeId, markerName). Lets the platform show
IReadOnlyCollection<(string RouteId, string MarkerName)> GetReplayMarkers()
GetRoutePolicy(string)
Returns the effective cluster-policy resolution for a compiled route.
RoutePolicyDescriptor GetRoutePolicy(string routeId)
GetServiceProvider()
Retrieves the registered , or null if not set.
IServiceProvider? GetServiceProvider()
GetThreadPoolProfile(string?)
The profile a detached step builds its pool from: the named one, or the context's default when
ThreadPoolProfile GetThreadPoolProfile(string? name)
HandleException(IExchange, Exception, CancellationToken)
Handles an exception using three-tier search order:
Task HandleException(IExchange exchange, Exception exception, CancellationToken ct = default)
HasComponent(string)
Returns whether a component with the specified scheme is registered.
bool HasComponent(string scheme)
HasExceptionRoute<TException>()
Checks whether an exception handler is registered (globally or locally)
bool HasExceptionRoute<TException>() where TException : Exception
RemoveComponent(string)
Removes a component by scheme. Returns true if removed.
bool RemoveComponent(string scheme)
ReplayAsync(string, string, IExchange, CancellationToken)
Re-runs the tail of a route from a captured checkpoint snapshot. Runs the compiled body of
Task ReplayAsync(string routeId, string markerName, IExchange snapshot, CancellationToken ct = default)
SetProperty<T>(string, T)
Sets a typed property. Returns this context for chaining.
IRouteContext SetProperty<T>(string key, T value)
SetServiceProvider(IServiceProvider)
Stores an for DI container integration.
IRouteContext SetServiceProvider(IServiceProvider serviceProvider)
Start(CancellationToken)
Starts all registered endpoints and consumers. Uses degraded-mode startup:
Task Start(CancellationToken ct = default)
StartRoute(string, CancellationToken)
Starts an individual route by its route ID.
Task StartRoute(string routeId, CancellationToken ct = default)
Stop(CancellationToken)
Stops all routes managed by this context.
Task Stop(CancellationToken ct = default)
StopRoute(string, CancellationToken)
Stops an individual route by its route ID.
Task StopRoute(string routeId, CancellationToken ct = default)
StopRoute(string, TimeSpan?, CancellationToken)
Stops an individual route with an optional timeout override.
Task StopRoute(string routeId, TimeSpan? timeout, CancellationToken ct = default)