pub struct Message {
pub headers: MessageHeaders,
pub properties: MessageProperties,
pub body: Vec<u8>,
pub content_type: String,
pub content_encoding: String,
}Expand description
Complete Celery message
Fields§
§headers: MessageHeadersMessage headers
properties: MessagePropertiesMessage properties
body: Vec<u8>Serialized body (task arguments)
content_type: StringContent type
content_encoding: StringContent encoding
Implementations§
Source§impl Message
impl Message
Sourcepub fn with_priority(self, priority: u8) -> Self
pub fn with_priority(self, priority: u8) -> Self
Set priority (0-9)
Sourcepub fn with_parent(self, parent_id: Uuid) -> Self
pub fn with_parent(self, parent_id: Uuid) -> Self
Set parent task ID
Sourcepub fn with_group(self, group: Uuid) -> Self
pub fn with_group(self, group: Uuid) -> Self
Set group ID
Sourcepub fn with_expires(self, expires: DateTime<Utc>) -> Self
pub fn with_expires(self, expires: DateTime<Utc>) -> Self
Set expiration
Sourcepub fn with_retries(self, retries: u32) -> Self
pub fn with_retries(self, retries: u32) -> Self
Set retry count
Sourcepub fn with_correlation_id(self, correlation_id: String) -> Self
pub fn with_correlation_id(self, correlation_id: String) -> Self
Set correlation ID (for RPC-style calls)
Sourcepub fn with_reply_to(self, reply_to: String) -> Self
pub fn with_reply_to(self, reply_to: String) -> Self
Set reply-to queue (for results)
Sourcepub fn with_delivery_mode(self, mode: u8) -> Self
pub fn with_delivery_mode(self, mode: u8) -> Self
Set delivery mode (1 = non-persistent, 2 = persistent)
Sourcepub fn validate(&self) -> Result<(), ValidationError>
pub fn validate(&self) -> Result<(), ValidationError>
Validate the complete message
Validates:
- Headers (task name, retries, eta/expires)
- Properties (delivery mode, priority)
- Content type format
- Body size
Sourcepub fn validate_with_limit(
&self,
max_body_bytes: usize,
) -> Result<(), ValidationError>
pub fn validate_with_limit( &self, max_body_bytes: usize, ) -> Result<(), ValidationError>
Validate with custom body size limit
Sourcepub fn has_expires(&self) -> bool
pub fn has_expires(&self) -> bool
Check if the message has an expiration time
Sourcepub fn has_parent(&self) -> bool
pub fn has_parent(&self) -> bool
Check if the message has a parent task
Sourcepub fn is_persistent(&self) -> bool
pub fn is_persistent(&self) -> bool
Check if the message is persistent
Sourcepub fn content_type_str(&self) -> &str
pub fn content_type_str(&self) -> &str
Get the content type as a string slice
Sourcepub fn content_encoding_str(&self) -> &str
pub fn content_encoding_str(&self) -> &str
Get the content encoding as a string slice
Sourcepub fn has_empty_body(&self) -> bool
pub fn has_empty_body(&self) -> bool
Check if the message body is empty
Sourcepub fn retry_count(&self) -> u32
pub fn retry_count(&self) -> u32
Get the retry count (0 if not set)
Sourcepub fn has_correlation_id(&self) -> bool
pub fn has_correlation_id(&self) -> bool
Check if message has a correlation ID
Sourcepub fn correlation_id(&self) -> Option<&str>
pub fn correlation_id(&self) -> Option<&str>
Get the correlation ID
Sourcepub fn is_workflow_message(&self) -> bool
pub fn is_workflow_message(&self) -> bool
Check if this is a workflow message (has parent, root, or group)
Sourcepub fn with_new_id(&self) -> Self
pub fn with_new_id(&self) -> Self
Clone the message with a new task ID
Sourcepub fn to_builder(&self) -> MessageBuilder
pub fn to_builder(&self) -> MessageBuilder
Create a builder from this message (for modification)
Note: This creates a new builder with the message’s metadata. The body (args/kwargs) must be set separately on the builder.
Sourcepub fn is_ready_for_execution(&self) -> bool
pub fn is_ready_for_execution(&self) -> bool
Check if the message is ready for immediate execution (not delayed)
Sourcepub fn is_not_expired(&self) -> bool
pub fn is_not_expired(&self) -> bool
Check if the message has not expired yet
Sourcepub fn should_process(&self) -> bool
pub fn should_process(&self) -> bool
Check if the message should be processed (not expired and ready for execution)
Sourcepub fn with_eta_delay(self, delay: Duration) -> Self
pub fn with_eta_delay(self, delay: Duration) -> Self
Set ETA to now + duration (builder pattern)
§Examples
use celers_protocol::Message;
use uuid::Uuid;
use chrono::Duration;
let msg = Message::new("task".to_string(), Uuid::new_v4(), vec![])
.with_eta_delay(Duration::minutes(5));
assert!(msg.has_eta());Sourcepub fn with_expires_in(self, duration: Duration) -> Self
pub fn with_expires_in(self, duration: Duration) -> Self
Set expiration to now + duration (builder pattern)
§Examples
use celers_protocol::Message;
use uuid::Uuid;
use chrono::Duration;
let msg = Message::new("task".to_string(), Uuid::new_v4(), vec![])
.with_expires_in(Duration::hours(1));
assert!(msg.has_expires());Sourcepub fn time_until_eta(&self) -> Option<Duration>
pub fn time_until_eta(&self) -> Option<Duration>
Get the time remaining until ETA (None if no ETA or already past)
Sourcepub fn time_until_expiration(&self) -> Option<Duration>
pub fn time_until_expiration(&self) -> Option<Duration>
Get the time remaining until expiration (None if no expiration or already expired)
Sourcepub fn increment_retry(&mut self) -> u32
pub fn increment_retry(&mut self) -> u32
Increment the retry count (returns new count)
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Extend<Message> for MessageBatch
impl Extend<Message> for MessageBatch
Source§fn extend<T: IntoIterator<Item = Message>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Message>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl Extend<Message> for MessagePriorityQueue
impl Extend<Message> for MessagePriorityQueue
Source§fn extend<T: IntoIterator<Item = Message>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Message>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl Extend<Message> for MultiLevelQueue
impl Extend<Message> for MultiLevelQueue
Source§fn extend<T: IntoIterator<Item = Message>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Message>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)