pub struct ConsumerContext { /* private fields */ }Expand description
Context provided to a Consumer, allowing it to send exchanges into the route.
Implementations§
Source§impl ConsumerContext
impl ConsumerContext
Sourcepub fn new(
sender: Sender<ExchangeEnvelope>,
cancel_token: CancellationToken,
) -> Self
pub fn new( sender: Sender<ExchangeEnvelope>, cancel_token: CancellationToken, ) -> Self
Create a new consumer context wrapping the given channel sender.
Sourcepub async fn cancelled(&self)
pub async fn cancelled(&self)
Returns a future that resolves when shutdown is requested.
Use in tokio::select! inside consumer loops.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Returns true if shutdown has been requested.
Sourcepub fn cancel_token(&self) -> CancellationToken
pub fn cancel_token(&self) -> CancellationToken
Returns a clone of the CancellationToken.
Useful for consumers that spawn per-request tasks and need to propagate
shutdown to each task. See HttpConsumer for an example.
Sourcepub fn sender(&self) -> Sender<ExchangeEnvelope>
pub fn sender(&self) -> Sender<ExchangeEnvelope>
Returns a clone of the channel sender for manual exchange submission.
Useful for consumers that spawn per-request tasks (e.g., HttpConsumer)
where each task independently sends exchanges into the pipeline.
For simple consumers, prefer send() or send_and_wait() instead.
Sourcepub async fn send(&self, exchange: Exchange) -> Result<(), CamelError>
pub async fn send(&self, exchange: Exchange) -> Result<(), CamelError>
Send an exchange into the route pipeline (fire-and-forget).
Sourcepub async fn send_and_wait(
&self,
exchange: Exchange,
) -> Result<Exchange, CamelError>
pub async fn send_and_wait( &self, exchange: Exchange, ) -> Result<Exchange, CamelError>
Send an exchange and wait for the pipeline result (request-reply).
Returns Ok(exchange) on success or Err(e) if the pipeline failed
without an error handler absorbing the error.
Trait Implementations§
Source§impl Clone for ConsumerContext
impl Clone for ConsumerContext
Source§fn clone(&self) -> ConsumerContext
fn clone(&self) -> ConsumerContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more