pub struct MessageBatchV2 { /* private fields */ }Expand description
Batch message container
Used for sending multiple messages in batch. Requires all messages to have the same topic and send properties.
§Constraints
- All messages must have the same topic
- All messages must have the same
wait_store_msg_okproperty - Delayed messages are not supported
- Retry topics are not supported
§Examples
use rocketmq_model::common::message::message_batch_v2::MessageBatchV2;
use rocketmq_model::common::message::message_single::Message;
let msg1 = Message::builder()
.topic("TopicTest")
.body_slice(b"Hello")
.build_unchecked();
let msg2 = Message::builder()
.topic("TopicTest")
.body_slice(b"World")
.build_unchecked();
let batch = MessageBatchV2::new(vec![msg1, msg2]).unwrap();
assert_eq!(batch.len(), 2);
assert_eq!(batch.topic().as_str(), "TopicTest");Implementations§
Source§impl MessageBatchV2
impl MessageBatchV2
Sourcepub fn new(messages: Vec<Message>) -> Result<Self>
pub fn new(messages: Vec<Message>) -> Result<Self>
Creates a batch message
§Errors
- Message list is empty
- Messages have different topics
- Contains delayed messages
- Contains retry topics
wait_store_msg_okproperties are inconsistent
Sourcepub fn topic(&self) -> &CheetahString
pub fn topic(&self) -> &CheetahString
Gets the batch message topic
Sourcepub fn wait_store_msg_ok(&self) -> bool
pub fn wait_store_msg_ok(&self) -> bool
Whether to wait for storage completion
Sourcepub fn into_messages(self) -> Vec<Message>
pub fn into_messages(self) -> Vec<Message>
Consumes the batch and returns the internal message list
Trait Implementations§
Source§impl Clone for MessageBatchV2
impl Clone for MessageBatchV2
Source§impl Debug for MessageBatchV2
impl Debug for MessageBatchV2
Source§impl Display for MessageBatchV2
impl Display for MessageBatchV2
Source§impl IntoIterator for MessageBatchV2
impl IntoIterator for MessageBatchV2
Source§impl<'a> IntoIterator for &'a MessageBatchV2
impl<'a> IntoIterator for &'a MessageBatchV2
Auto Trait Implementations§
impl Freeze for MessageBatchV2
impl RefUnwindSafe for MessageBatchV2
impl Send for MessageBatchV2
impl Sync for MessageBatchV2
impl Unpin for MessageBatchV2
impl UnsafeUnpin for MessageBatchV2
impl UnwindSafe for MessageBatchV2
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more