pub trait BaseConsumer<T>:
Send
+ Sync
+ 'static{
// Required method
fn handle<'life0, 'async_trait>(
&'life0 self,
message: T,
context: MessageContext,
) -> Pin<Box<dyn Future<Output = Result<(), ProcessingError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Base consumer trait for processing messages with smart retry handling
This trait provides a simplified interface where:
- Messages are automatically ACK’d after successful processing
- Retryable errors automatically publish to delay exchange
- Non-retryable errors send to DLQ or discard based on configuration
Required Methods§
Sourcefn handle<'life0, 'async_trait>(
&'life0 self,
message: T,
context: MessageContext,
) -> Pin<Box<dyn Future<Output = Result<(), ProcessingError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn handle<'life0, 'async_trait>(
&'life0 self,
message: T,
context: MessageContext,
) -> Pin<Box<dyn Future<Output = Result<(), ProcessingError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Process a message and return the result
§Returns
Ok(())- Message processed successfully, will be ACK’d automaticallyErr(ProcessingError::Retryable { .. })- Will retry with delay exchangeErr(ProcessingError::NonRetryable { .. })- Will reject/send to DLQ