pub trait MessagePoll: Send + Sync {
Show 24 methods
// Required methods
async fn poll_zero_copy(&self) -> Vec<Arc<MessageExt>>;
async fn poll_with_timeout_zero_copy(
&self,
timeout: u64,
) -> Vec<Arc<MessageExt>>;
async fn poll(&self) -> Vec<MessageExt>;
async fn poll_with_timeout(&self, timeout: u64) -> Vec<MessageExt>;
async fn poll_timeout_millis(&self) -> u64;
async fn set_poll_timeout_millis(&self, timeout_millis: u64);
async fn broker_suspend_max_time_millis(&self) -> u64;
async fn set_broker_suspend_max_time_millis(&self, timeout_millis: u64);
async fn consumer_timeout_millis_when_suspend(&self) -> u64;
async fn set_consumer_timeout_millis_when_suspend(
&self,
timeout_millis: u64,
);
async fn consumer_pull_timeout_millis(&self) -> u64;
async fn set_consumer_pull_timeout_millis(&self, timeout_millis: u64);
async fn pull_batch_size(&self) -> i32;
async fn set_pull_batch_size(&self, pull_batch_size: i32);
async fn pull_thread_nums(&self) -> usize;
async fn set_pull_thread_nums(&self, pull_thread_nums: usize);
async fn pull_threshold_for_all(&self) -> i64;
async fn set_pull_threshold_for_all(&self, pull_threshold_for_all: i64);
async fn pull_threshold_for_queue(&self) -> i64;
async fn set_pull_threshold_for_queue(&self, pull_threshold_for_queue: i64);
async fn pull_threshold_size_for_queue(&self) -> i32;
async fn set_pull_threshold_size_for_queue(
&self,
pull_threshold_size_for_queue: i32,
);
async fn consume_max_span(&self) -> i64;
async fn set_consume_max_span(&self, consume_max_span: i64);
}Required Methods§
Sourceasync fn poll_zero_copy(&self) -> Vec<Arc<MessageExt>>
async fn poll_zero_copy(&self) -> Vec<Arc<MessageExt>>
Fetches the next batch of messages without allocating owned copies.
Returns immutable Arc<MessageExt> handles without heap allocation or deep cloning.
The returned handles remain valid until
they are dropped. Messages that need to outlive the poll scope must be cloned explicitly.
This method uses the default poll timeout configured for the consumer.
§Performance
Message contents are not copied. For workloads processing messages without long-term
storage, this eliminates allocation overhead compared to poll().
§Examples
let messages = consumer.poll_zero_copy().await;
for msg in &messages {
process_message(msg);
}
// Clone only filtered messages
let messages = consumer.poll_zero_copy().await;
let important: Vec<MessageExt> = messages.into_iter()
.filter(|msg| is_important(msg))
.map(|msg| (*msg).clone())
.collect();Returns an empty vector if no messages are available within the default timeout period. This function does not block the calling thread.
Sourceasync fn poll_with_timeout_zero_copy(
&self,
timeout: u64,
) -> Vec<Arc<MessageExt>>
async fn poll_with_timeout_zero_copy( &self, timeout: u64, ) -> Vec<Arc<MessageExt>>
Fetches the next batch of messages without allocating owned copies, with a specified timeout.
Behaves identically to poll_zero_copy(), but waits up to timeout milliseconds
for messages to become available.
§Arguments
timeout- Maximum time to wait for messages, in milliseconds.
§Examples
let messages = consumer.poll_with_timeout_zero_copy(1000).await;Returns an empty vector if no messages are available before the timeout expires. This function does not block the calling thread.
Sourceasync fn poll(&self) -> Vec<MessageExt>
async fn poll(&self) -> Vec<MessageExt>
Fetches the next batch of messages, returning owned copies.
Each returned message is cloned from the internal message store. The caller owns the returned messages and may store them beyond the poll scope.
This method uses the default poll timeout configured for the consumer.
§Performance
All messages are deep-cloned, including message body and properties. For a 2KB message, each poll returning 32 messages allocates approximately 90KB. At 100 polls per second, this results in approximately 9MB/s of allocations.
For workloads that do not require owned messages, poll_zero_copy() avoids
this allocation overhead.
§Examples
let messages = consumer.poll().await;
my_store.save(messages);Returns an empty vector if no messages are available within the timeout period. This function does not block the calling thread.
Sourceasync fn poll_with_timeout(&self, timeout: u64) -> Vec<MessageExt>
async fn poll_with_timeout(&self, timeout: u64) -> Vec<MessageExt>
Fetches the next batch of messages with a specified timeout, returning owned copies.
Behaves identically to poll(), but waits up to timeout milliseconds for
messages to become available. All messages are deep-cloned.
§Arguments
timeout- Maximum time to wait for messages, in milliseconds.
Returns an empty vector if no messages are available before the timeout expires. This function does not block the calling thread.
Sourceasync fn poll_timeout_millis(&self) -> u64
async fn poll_timeout_millis(&self) -> u64
Returns the default timeout used by poll in milliseconds.
This function does not block the calling thread.
Sourceasync fn set_poll_timeout_millis(&self, timeout_millis: u64)
async fn set_poll_timeout_millis(&self, timeout_millis: u64)
Sets the default timeout used by poll in milliseconds.
This follows the Java client setter and applies the value directly. Use
poll_with_timeout for a per-call timeout override.
This function does not block the calling thread.
Sourceasync fn broker_suspend_max_time_millis(&self) -> u64
async fn broker_suspend_max_time_millis(&self) -> u64
Returns the maximum time that the broker may suspend a long-poll pull request.
Sourceasync fn set_broker_suspend_max_time_millis(&self, timeout_millis: u64)
async fn set_broker_suspend_max_time_millis(&self, timeout_millis: u64)
Sets the maximum time that the broker may suspend a long-poll pull request.
This follows Java DefaultLitePullConsumer.setBrokerSuspendMaxTimeMillis
and applies the value directly.
Sourceasync fn consumer_timeout_millis_when_suspend(&self) -> u64
async fn consumer_timeout_millis_when_suspend(&self) -> u64
Returns the consumer-side timeout for suspended long-poll pull requests.
Sourceasync fn set_consumer_timeout_millis_when_suspend(&self, timeout_millis: u64)
async fn set_consumer_timeout_millis_when_suspend(&self, timeout_millis: u64)
Sets the consumer-side timeout for suspended long-poll pull requests.
This follows Java DefaultLitePullConsumer.setConsumerTimeoutMillisWhenSuspend
and applies the value directly.
Sourceasync fn consumer_pull_timeout_millis(&self) -> u64
async fn consumer_pull_timeout_millis(&self) -> u64
Returns the RPC timeout used by lite pull requests in milliseconds.
Sourceasync fn set_consumer_pull_timeout_millis(&self, timeout_millis: u64)
async fn set_consumer_pull_timeout_millis(&self, timeout_millis: u64)
Sets the RPC timeout used by lite pull requests in milliseconds.
This follows Java DefaultLitePullConsumer.setConsumerPullTimeoutMillis
and applies the value directly.
Sourceasync fn pull_batch_size(&self) -> i32
async fn pull_batch_size(&self) -> i32
Returns the maximum number of messages requested in a single pull.
Sourceasync fn set_pull_batch_size(&self, pull_batch_size: i32)
async fn set_pull_batch_size(&self, pull_batch_size: i32)
Sets the maximum number of messages requested in a single pull.
This follows the Java client setter and applies the value directly.
Sourceasync fn pull_thread_nums(&self) -> usize
async fn pull_thread_nums(&self) -> usize
Returns the configured number of pull worker threads.
Sourceasync fn set_pull_thread_nums(&self, pull_thread_nums: usize)
async fn set_pull_thread_nums(&self, pull_thread_nums: usize)
Sets the configured number of pull worker threads.
This mirrors Java DefaultLitePullConsumer.setPullThreadNums.
Sourceasync fn pull_threshold_for_all(&self) -> i64
async fn pull_threshold_for_all(&self) -> i64
Returns the maximum total number of cached messages across all queues.
Sourceasync fn set_pull_threshold_for_all(&self, pull_threshold_for_all: i64)
async fn set_pull_threshold_for_all(&self, pull_threshold_for_all: i64)
Sets the maximum total number of cached messages across all queues.
This follows the Java client setter and applies the value directly.
Sourceasync fn pull_threshold_for_queue(&self) -> i64
async fn pull_threshold_for_queue(&self) -> i64
Returns the maximum cached message count for each queue.
Sourceasync fn set_pull_threshold_for_queue(&self, pull_threshold_for_queue: i64)
async fn set_pull_threshold_for_queue(&self, pull_threshold_for_queue: i64)
Sets the maximum cached message count for each queue.
This follows the Java client setter and applies the value directly.
Sourceasync fn pull_threshold_size_for_queue(&self) -> i32
async fn pull_threshold_size_for_queue(&self) -> i32
Returns the maximum cached message size in MiB for each queue.
Sourceasync fn set_pull_threshold_size_for_queue(
&self,
pull_threshold_size_for_queue: i32,
)
async fn set_pull_threshold_size_for_queue( &self, pull_threshold_size_for_queue: i32, )
Sets the maximum cached message size in MiB for each queue.
This follows the Java client setter and applies the value directly.
Sourceasync fn consume_max_span(&self) -> i64
async fn consume_max_span(&self) -> i64
Returns the maximum allowed offset span in a cached process queue.
Sourceasync fn set_consume_max_span(&self, consume_max_span: i64)
async fn set_consume_max_span(&self, consume_max_span: i64)
Sets the maximum allowed offset span in a cached process queue.
This follows the Java client setter and applies the value directly.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".