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 !Freeze for Producer
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§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