pub trait MQPushConsumer: MQConsumer {
// Required methods
async fn start(&mut self) -> ClientResult<()>;
async fn shutdown(&mut self);
fn register_message_listener_concurrently<ML>(
&mut self,
message_listener: ML,
)
where ML: MessageListenerConcurrently + Send + Sync + 'static;
fn register_message_listener_orderly<ML>(&mut self, message_listener: ML)
where ML: MessageListenerOrderly + Send + Sync + 'static;
async fn subscribe(
&mut self,
topic: impl Into<CheetahString>,
sub_expression: impl Into<CheetahString>,
) -> ClientResult<()>;
async fn subscribe_with_selector(
&mut self,
topic: &str,
selector: Option<MessageSelector>,
) -> ClientResult<()>;
async fn unsubscribe(&mut self, topic: &str);
async fn suspend(&self);
async fn resume(&self);
// Provided method
fn update_core_pool_size(&self, _core_pool_size: usize) -> ClientResult<()> { ... }
}Expand description
Defines the push-consumer interface for RocketMQ.
Implementations receive messages from brokers and dispatch them to the registered concurrent or orderly listener.
Required Methods§
Sourceasync fn start(&mut self) -> ClientResult<()>
async fn start(&mut self) -> ClientResult<()>
Asynchronously starts the consumer instance.
This method does not block the calling thread.
§Returns
Returns Ok(()) when startup succeeds, or an error when initialization
fails.
Sourceasync fn shutdown(&mut self)
async fn shutdown(&mut self)
Asynchronously shuts down the consumer instance.
This method does not block the calling thread.
Sourcefn register_message_listener_concurrently<ML>(&mut self, message_listener: ML)
fn register_message_listener_concurrently<ML>(&mut self, message_listener: ML)
Sourcefn register_message_listener_orderly<ML>(&mut self, message_listener: ML)
fn register_message_listener_orderly<ML>(&mut self, message_listener: ML)
Sourceasync fn subscribe(
&mut self,
topic: impl Into<CheetahString>,
sub_expression: impl Into<CheetahString>,
) -> ClientResult<()>
async fn subscribe( &mut self, topic: impl Into<CheetahString>, sub_expression: impl Into<CheetahString>, ) -> ClientResult<()>
Asynchronously subscribes to a topic with a subscription expression.
This method does not block the calling thread.
§Parameters
topic- The topic to subscribe to. Can be&str,String, orCheetahString.sub_expression- The subscription expression. Can be&str,String, orCheetahString.
§Returns
Returns Ok(()) when the subscription is accepted, or an error when the
subscription request is invalid or cannot be applied.
§Examples
// Using &str
consumer.subscribe("TopicTest", "*").await?;
// Using String
let topic = String::from("TopicTest");
consumer.subscribe(topic, "*").await?;
// Using CheetahString
let topic = CheetahString::from_slice("TopicTest");
consumer.subscribe(topic, "*").await?;Sourceasync fn subscribe_with_selector(
&mut self,
topic: &str,
selector: Option<MessageSelector>,
) -> ClientResult<()>
async fn subscribe_with_selector( &mut self, topic: &str, selector: Option<MessageSelector>, ) -> ClientResult<()>
Asynchronously subscribes to a topic with an optional selector.
This method does not block the calling thread.
§Parameters
topic- The topic to subscribe to.selector- An optional message selector.
§Returns
Returns Ok(()) when the subscription is accepted, or an error when the
selector is invalid or cannot be applied.
Sourceasync fn unsubscribe(&mut self, topic: &str)
async fn unsubscribe(&mut self, topic: &str)
Asynchronously unsubscribes from a topic.
This method does not block the calling thread.
§Parameters
topic- The topic to unsubscribe from.
Provided Methods§
Sourcefn update_core_pool_size(&self, _core_pool_size: usize) -> ClientResult<()>
fn update_core_pool_size(&self, _core_pool_size: usize) -> ClientResult<()>
Updates the core size used by the concurrent consume worker pool.
Orderly consumers and implementations without a resizable worker pool may ignore this request.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".