pub struct Message { /* private fields */ }Implementations§
Source§impl Message
impl Message
Sourcepub fn builder() -> MessageBuilder
pub fn builder() -> MessageBuilder
Creates a new message builder.
This is the recommended way to create messages.
§Examples
use rocketmq_model::common::message::message_single::Message;
let msg = Message::builder()
.topic("test-topic")
.body_slice(b"hello world")
.tags("important")
.build_unchecked();Sourcepub fn new(topic: impl Into<CheetahString>, body: &[u8]) -> Self
👎Deprecated since 0.8.0: Use Message::builder() instead
pub fn new(topic: impl Into<CheetahString>, body: &[u8]) -> Self
Use Message::builder() instead
Create a new message with topic and body slice (will copy)
Sourcepub fn new_with_bytes(topic: impl Into<CheetahString>, body: Bytes) -> Self
👎Deprecated since 0.8.0: Use Message::builder() instead
pub fn new_with_bytes(topic: impl Into<CheetahString>, body: Bytes) -> Self
Use Message::builder() instead
Create a new message with topic and Bytes (zero-copy)
Sourcepub fn new_with_vec(topic: impl Into<CheetahString>, body: Vec<u8>) -> Self
👎Deprecated since 0.8.0: Use Message::builder() instead
pub fn new_with_vec(topic: impl Into<CheetahString>, body: Vec<u8>) -> Self
Use Message::builder() instead
Create a new message with topic and Vec<u8> (zero-copy conversion to Bytes)
pub fn new_body(topic: impl Into<CheetahString>, body: Option<Bytes>) -> Self
Use Message::builder() instead
👎Deprecated since 0.8.0: Use Message::builder() instead
Use Message::builder() instead
Create a message with tags and body slice (will copy)
👎Deprecated since 0.8.0: Use Message::builder() instead
Use Message::builder() instead
Create a message with tags and Bytes (zero-copy)
Sourcepub fn with_keys(
topic: impl Into<CheetahString>,
tags: impl Into<CheetahString>,
keys: impl Into<CheetahString>,
body: &[u8],
) -> Self
👎Deprecated since 0.8.0: Use Message::builder() instead
pub fn with_keys( topic: impl Into<CheetahString>, tags: impl Into<CheetahString>, keys: impl Into<CheetahString>, body: &[u8], ) -> Self
Use Message::builder() instead
Create a message with keys and body slice (will copy)
Sourcepub fn with_keys_bytes(
topic: impl Into<CheetahString>,
tags: impl Into<CheetahString>,
keys: impl Into<CheetahString>,
body: Bytes,
) -> Self
👎Deprecated since 0.8.0: Use Message::builder() instead
pub fn with_keys_bytes( topic: impl Into<CheetahString>, tags: impl Into<CheetahString>, keys: impl Into<CheetahString>, body: Bytes, ) -> Self
Use Message::builder() instead
Create a message with keys and Bytes (zero-copy)
Sourcepub fn with_details(
topic: impl Into<CheetahString>,
tags: impl Into<CheetahString>,
keys: impl Into<CheetahString>,
flag: i32,
body: &[u8],
wait_store_msg_ok: bool,
) -> Self
👎Deprecated since 0.8.0: Use Message::builder() instead
pub fn with_details( topic: impl Into<CheetahString>, tags: impl Into<CheetahString>, keys: impl Into<CheetahString>, flag: i32, body: &[u8], wait_store_msg_ok: bool, ) -> Self
Use Message::builder() instead
Create message with body slice (will copy data)
Sourcepub fn with_details_bytes(
topic: impl Into<CheetahString>,
tags: impl Into<CheetahString>,
keys: impl Into<CheetahString>,
flag: i32,
body: Bytes,
wait_store_msg_ok: bool,
) -> Self
👎Deprecated since 0.8.0: Use Message::builder() instead
pub fn with_details_bytes( topic: impl Into<CheetahString>, tags: impl Into<CheetahString>, keys: impl Into<CheetahString>, flag: i32, body: Bytes, wait_store_msg_ok: bool, ) -> Self
Use Message::builder() instead
Create message with Bytes (zero-copy)
pub fn with_details_body( topic: impl Into<CheetahString>, tags: impl Into<CheetahString>, keys: impl Into<CheetahString>, flag: i32, body: Option<Bytes>, wait_store_msg_ok: bool, ) -> Self
pub fn set_keys(&mut self, keys: CheetahString)
pub fn clear_property(&mut self, name: impl Into<CheetahString>)
pub fn set_properties( &mut self, properties: HashMap<CheetahString, CheetahString>, )
pub fn get_property(&self, key: &CheetahString) -> Option<CheetahString>
pub fn body(&self) -> Option<Bytes>
pub fn flag(&self) -> i32
pub fn topic(&self) -> &CheetahString
pub fn properties(&self) -> &MessageProperties
pub fn transaction_id(&self) -> Option<&str>
pub fn get_transaction_id(&self) -> Option<&CheetahString>
pub fn is_wait_store_msg_ok(&self) -> bool
pub fn delay_time_level(&self) -> i32
pub fn set_delay_time_level(&mut self, level: i32)
pub fn get_user_property( &self, name: impl Into<CheetahString>, ) -> Option<CheetahString>
pub fn as_any(&self) -> &dyn Any
pub fn set_instance_id(&mut self, instance_id: impl Into<CheetahString>)
Sourcepub fn body_slice(&self) -> &[u8] ⓘ
pub fn body_slice(&self) -> &[u8] ⓘ
Returns the message body as a byte slice (borrows).
This is the recommended way to access the message body.
Sourcepub fn into_body(self) -> MessageBody
pub fn into_body(self) -> MessageBody
Consumes the message and returns the body.
Returns the message tags.
Sourcepub fn message_flag(&self) -> MessageFlag
pub fn message_flag(&self) -> MessageFlag
Returns the message flag as a type-safe MessageFlag.
Sourcepub fn wait_store_msg_ok(&self) -> bool
pub fn wait_store_msg_ok(&self) -> bool
Returns whether to wait for store confirmation.
Sourcepub fn delay_level(&self) -> i32
pub fn delay_level(&self) -> i32
Returns the delay time level.
Sourcepub fn try_set_priority(&mut self, priority: i32) -> Result<()>
pub fn try_set_priority(&mut self, priority: i32) -> Result<()>
Sets the message priority with Java-compatible non-negative validation.
Sourcepub fn instance_id(&self) -> Option<&str>
pub fn instance_id(&self) -> Option<&str>
Returns the instance ID.