pub struct CamelContext { /* private fields */ }Expand description
Implementations§
Source§impl CamelContext
impl CamelContext
pub fn builder() -> CamelContextBuilder
Sourcepub async fn set_error_handler(&mut self, config: ErrorHandlerConfig)
pub async fn set_error_handler(&mut self, config: ErrorHandlerConfig)
Set a global error handler applied to all routes without a per-route handler.
Sourcepub async fn set_tracing(&mut self, enabled: bool)
pub async fn set_tracing(&mut self, enabled: bool)
Enable or disable tracing globally.
Sourcepub async fn set_tracer_config(&mut self, config: TracerConfig)
pub async fn set_tracer_config(&mut self, config: TracerConfig)
Configure tracing with full config.
Sourcepub async fn with_tracing(self) -> Self
pub async fn with_tracing(self) -> Self
Builder-style: enable tracing with default config.
Sourcepub async fn with_tracer_config(self, config: TracerConfig) -> Self
pub async fn with_tracer_config(self, config: TracerConfig) -> Self
Builder-style: configure tracing with custom config. Note: tracing subscriber initialization (stdout/file output) is handled separately via init_tracing_subscriber (called in camel-config bridge).
Sourcepub fn with_lifecycle<L: Lifecycle + 'static>(self, service: L) -> Self
pub fn with_lifecycle<L: Lifecycle + 'static>(self, service: L) -> Self
Register a lifecycle service (Apache Camel: addService pattern)
For services exposing as_function_invoker(), the invoker is propagated
to the route controller so that subsequent route definitions with function
steps work correctly.
Prefer CamelContextBuilder::with_lifecycle when possible, which wires
the invoker at build time before any routes are added.
Sourcepub fn register_component<C: Component + 'static>(&mut self, component: C)
pub fn register_component<C: Component + 'static>(&mut self, component: C)
Register a component with this context.
Sourcepub fn add_startup_check(&mut self, check: Box<dyn ConfigCheck>)
pub fn add_startup_check(&mut self, check: Box<dyn ConfigCheck>)
Register a startup ConfigCheck to be evaluated at the head of
start(). Established by ADR-0033.
Checks are drained and executed synchronously before any route consumer
is started. If any check returns Err, start() fails closed with
CamelError::Config(_) and no route is started. The check list is
consumed (moved) during start() so this method may be called multiple
times to register an arbitrary number of checks.
Sourcepub fn register_language(
&mut self,
name: impl Into<String>,
lang: Box<dyn Language>,
) -> Result<(), LanguageRegistryError>
pub fn register_language( &mut self, name: impl Into<String>, lang: Box<dyn Language>, ) -> Result<(), LanguageRegistryError>
Register a language with this context, keyed by name.
Returns Err(LanguageRegistryError::AlreadyRegistered) if a language
with the same name is already registered. Use
resolve_language to check before
registering, or choose a distinct name.
Sourcepub fn resolve_language(&self, name: &str) -> Option<Arc<dyn Language>>
pub fn resolve_language(&self, name: &str) -> Option<Arc<dyn Language>>
Resolve a language by name. Returns None if not registered.
Sourcepub async fn add_route_definition(
&self,
definition: RouteDefinition,
) -> Result<(), CamelError>
pub async fn add_route_definition( &self, definition: RouteDefinition, ) -> Result<(), CamelError>
Add a route definition to this context.
The route must have an ID. Steps are resolved immediately using registered components.
Sourcepub fn registry(&self) -> MutexGuard<'_, Registry>
pub fn registry(&self) -> MutexGuard<'_, Registry>
Access the component registry.
Sourcepub fn runtime_execution_handle(&self) -> RuntimeExecutionHandle
pub fn runtime_execution_handle(&self) -> RuntimeExecutionHandle
Get runtime execution handle for file-watcher integrations.
Sourcepub fn metrics(&self) -> Arc<dyn MetricsCollector> ⓘ
pub fn metrics(&self) -> Arc<dyn MetricsCollector> ⓘ
Get the metrics collector.
Sourcepub fn platform_service(&self) -> Arc<dyn PlatformService> ⓘ
pub fn platform_service(&self) -> Arc<dyn PlatformService> ⓘ
Get the platform service.
Sourcepub fn readiness_gate(&self) -> Arc<dyn ReadinessGate> ⓘ
pub fn readiness_gate(&self) -> Arc<dyn ReadinessGate> ⓘ
Get the readiness gate port.
Sourcepub fn platform_identity(&self) -> PlatformIdentity
pub fn platform_identity(&self) -> PlatformIdentity
Get the platform identity.
Sourcepub fn leadership(&self) -> Arc<dyn LeadershipService> ⓘ
pub fn leadership(&self) -> Arc<dyn LeadershipService> ⓘ
Get the leadership service port.
Sourcepub fn runtime(&self) -> Arc<dyn RuntimeHandle> ⓘ
pub fn runtime(&self) -> Arc<dyn RuntimeHandle> ⓘ
Get runtime command/query bus handle.
Sourcepub fn producer_context(&self) -> ProducerContext
pub fn producer_context(&self) -> ProducerContext
Build a producer context wired to this runtime.
Sourcepub async fn runtime_route_status(
&self,
route_id: &str,
) -> Result<Option<String>, CamelError>
pub async fn runtime_route_status( &self, route_id: &str, ) -> Result<Option<String>, CamelError>
Query route status via runtime read-model.
Sourcepub async fn start(&mut self) -> Result<(), CamelError>
pub async fn start(&mut self) -> Result<(), CamelError>
Start all routes. Each route’s consumer will begin producing exchanges.
Only routes with auto_startup == true will be started, in order of their
startup_order (lower values start first).
Sourcepub async fn stop(&mut self) -> Result<(), CamelError>
pub async fn stop(&mut self) -> Result<(), CamelError>
Graceful shutdown with default 30-second timeout.
Sourcepub async fn stop_timeout(
&mut self,
_timeout: Duration,
) -> Result<(), CamelError>
pub async fn stop_timeout( &mut self, _timeout: Duration, ) -> Result<(), CamelError>
Graceful shutdown with custom timeout.
Note: The timeout parameter is currently not propagated to the
RouteController’s per-route shutdown timeout. The RouteController
uses a hardcoded 5-second default (DEFAULT_SHUTDOWN_TIMEOUT).
Full propagation is planned for a future version.
Sourcepub fn shutdown_timeout(&self) -> Duration
pub fn shutdown_timeout(&self) -> Duration
Get the graceful shutdown timeout used by stop().
Sourcepub fn set_shutdown_timeout(&mut self, timeout: Duration)
pub fn set_shutdown_timeout(&mut self, timeout: Duration)
Set the graceful shutdown timeout used by stop().
Sourcepub async fn health_check(&self) -> HealthReport
pub async fn health_check(&self) -> HealthReport
Check health status of all registered services and lifecycle services.
pub fn health_registry(&self) -> Arc<HealthCheckRegistry> ⓘ
Sourcepub fn set_component_config<T: 'static + Send + Sync>(&mut self, config: T)
pub fn set_component_config<T: 'static + Send + Sync>(&mut self, config: T)
Store a component config. Overwrites any previously stored config of the same type.
Sourcepub fn get_component_config<T: 'static + Send + Sync>(&self) -> Option<&T>
pub fn get_component_config<T: 'static + Send + Sync>(&self) -> Option<&T>
Retrieve a stored component config by type. Returns None if not stored.
Sourcepub fn add_route_template(
&self,
spec: RouteTemplateSpec,
) -> Result<(), CamelError>
pub fn add_route_template( &self, spec: RouteTemplateSpec, ) -> Result<(), CamelError>
Register a route template specification.
Returns Err(CamelError) if a template with the same ID is already registered.
Sourcepub fn get_route_template(&self, id: &str) -> Option<RouteTemplateSpec>
pub fn get_route_template(&self, id: &str) -> Option<RouteTemplateSpec>
Retrieve a route template specification by its ID.
Sourcepub fn template_ids(&self) -> Vec<String>
pub fn template_ids(&self) -> Vec<String>
Return all registered template IDs.
Sourcepub fn record_template_instance(&self, record: TemplateInstanceRecord)
pub fn record_template_instance(&self, record: TemplateInstanceRecord)
Record a newly instantiated template instance.
Sourcepub fn template_instances(
&self,
template_id: &str,
) -> Vec<TemplateInstanceRecord>
pub fn template_instances( &self, template_id: &str, ) -> Vec<TemplateInstanceRecord>
Return all instance records for a given template ID.
Sourcepub fn register_idempotent_repository(
&mut self,
name: impl Into<String>,
repo: Arc<dyn IdempotentRepository>,
) -> Result<(), RegistryError>
pub fn register_idempotent_repository( &mut self, name: impl Into<String>, repo: Arc<dyn IdempotentRepository>, ) -> Result<(), RegistryError>
Register an idempotent repository.
Returns Err(RegistryError::AlreadyRegistered) if a repository with
the same name is already registered.
Sourcepub fn idempotent_repository(
&self,
name: &str,
) -> Option<Arc<dyn IdempotentRepository>>
pub fn idempotent_repository( &self, name: &str, ) -> Option<Arc<dyn IdempotentRepository>>
Retrieve an idempotent repository by name.
Sourcepub fn register_claim_check_repository(
&mut self,
name: impl Into<String>,
repo: Arc<dyn ClaimCheckRepository>,
) -> Result<(), RegistryError>
pub fn register_claim_check_repository( &mut self, name: impl Into<String>, repo: Arc<dyn ClaimCheckRepository>, ) -> Result<(), RegistryError>
Register a claim check repository.
Returns Err(RegistryError::AlreadyRegistered) if a repository with
the same name is already registered.
Sourcepub fn claim_check_repository(
&self,
name: &str,
) -> Option<Arc<dyn ClaimCheckRepository>>
pub fn claim_check_repository( &self, name: &str, ) -> Option<Arc<dyn ClaimCheckRepository>>
Retrieve a claim check repository by name.