pub trait MessageHandler: Send + Sync {
type MessageType: for<'de> Deserialize<'de> + Send + Sync;
// Required methods
fn handle_message<'life0, 'async_trait>(
&'life0 self,
message: Self::MessageType,
) -> Pin<Box<dyn Future<Output = Result<(), WorkerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn handler_name(&self) -> &str;
}Expand description
A trait for processing messages from a RabbitMQ queue.
Implement this trait for your specific message type and business logic.
Required Associated Types§
Sourcetype MessageType: for<'de> Deserialize<'de> + Send + Sync
type MessageType: for<'de> Deserialize<'de> + Send + Sync
The type of the message that this handler can process. Must be deserializable from JSON.
Required Methods§
Sourcefn handle_message<'life0, 'async_trait>(
&'life0 self,
message: Self::MessageType,
) -> Pin<Box<dyn Future<Output = Result<(), WorkerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn handle_message<'life0, 'async_trait>(
&'life0 self,
message: Self::MessageType,
) -> Pin<Box<dyn Future<Output = Result<(), WorkerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sourcefn handler_name(&self) -> &str
fn handler_name(&self) -> &str
A name for the handler, used for logging and identification.