pub struct Producer { /* private fields */ }
Expand description
Producer
is the core struct, to which application developers should turn, when publishing messages to RocketMQ proxy.
Producer
is a thin wrapper of internal client struct that shoulders the actual workloads.
Most of its methods take shared reference so that application developers may use it at will.
Producer
is Send
and Sync
by design, so that developers may get started easily.
Implementations§
source§impl Producer
impl Producer
sourcepub fn new(
option: ProducerOption,
client_option: ClientOption
) -> Result<Self, ClientError>
pub fn new( option: ProducerOption, client_option: ClientOption ) -> Result<Self, ClientError>
sourcepub fn new_transaction_producer(
option: ProducerOption,
client_option: ClientOption,
transaction_checker: Box<TransactionChecker>
) -> Result<Self, ClientError>
pub fn new_transaction_producer( option: ProducerOption, client_option: ClientOption, transaction_checker: Box<TransactionChecker> ) -> Result<Self, ClientError>
Create a new transaction producer instance
Arguments
option
- producer optionclient_option
- client optiontransaction_checker
- handle server query for uncommitted transaction status
sourcepub async fn start(&mut self) -> Result<(), ClientError>
pub async fn start(&mut self) -> Result<(), ClientError>
Start the producer
sourcepub async fn send(
&self,
message: impl Message
) -> Result<SendReceipt, ClientError>
pub async fn send( &self, message: impl Message ) -> Result<SendReceipt, ClientError>
sourcepub async fn batch_send(
&self,
messages: Vec<impl Message>
) -> Result<Vec<SendReceipt>, ClientError>
pub async fn batch_send( &self, messages: Vec<impl Message> ) -> Result<Vec<SendReceipt>, ClientError>
sourcepub async fn send_transaction_message(
&self,
message: impl Message
) -> Result<impl Transaction, ClientError>
pub async fn send_transaction_message( &self, message: impl Message ) -> Result<impl Transaction, ClientError>
Send message in a transaction
pub async fn shutdown(self) -> Result<(), ClientError>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Producer
impl Send for Producer
impl Sync for Producer
impl Unpin for Producer
impl !UnwindSafe for Producer
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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request