pub trait QueueConsumer: Send + Sync {
// Required method
fn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 Message,
) -> Pin<Box<dyn Future<Output = Result<(), QueueConsumerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
队列消费者 trait
业务侧实现该 trait,处理从队列消费的消息。
§行为契约
- 返回
Ok(()):自动调用queue.ack(message_id)确认消息 - 返回
Err(_):不 ack(消息留在in_flight,需人工干预或超时重投)
Required Methods§
Sourcefn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 Message,
) -> Pin<Box<dyn Future<Output = Result<(), QueueConsumerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 Message,
) -> Pin<Box<dyn Future<Output = Result<(), QueueConsumerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
处理一条消息
- 成功返回
Ok(())会触发自动 ack - 失败返回
Err(_)会跳过 ack(消息留在 in_flight)
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".