Struct rdkafka::producer::ThreadedProducer
source · pub struct ThreadedProducer<C>where
C: ProducerContext + 'static,{ /* private fields */ }
Expand description
A low-level Kafka producer with a separate thread for event handling.
The ThreadedProducer
is a BaseProducer
with a separate thread
dedicated to calling poll
at regular intervals in order to execute any
queued events, such as delivery notifications. The thread will be
automatically stopped when the producer is dropped.
Implementations§
source§impl<C> ThreadedProducer<C>where
C: ProducerContext + 'static,
impl<C> ThreadedProducer<C>where
C: ProducerContext + 'static,
sourcepub fn send<'a, K, P>(
&self,
record: BaseRecord<'a, K, P, C::DeliveryOpaque>,
) -> Result<(), (KafkaError, BaseRecord<'a, K, P, C::DeliveryOpaque>)>
pub fn send<'a, K, P>( &self, record: BaseRecord<'a, K, P, C::DeliveryOpaque>, ) -> Result<(), (KafkaError, BaseRecord<'a, K, P, C::DeliveryOpaque>)>
Sends a message to Kafka.
See the documentation for BaseProducer::send
for details.
Trait Implementations§
source§impl<C: ProducerContext + 'static> Clone for ThreadedProducer<C>
impl<C: ProducerContext + 'static> Clone for ThreadedProducer<C>
source§impl<C> Drop for ThreadedProducer<C>where
C: ProducerContext + 'static,
impl<C> Drop for ThreadedProducer<C>where
C: ProducerContext + 'static,
source§impl FromClientConfig for ThreadedProducer<DefaultProducerContext>
impl FromClientConfig for ThreadedProducer<DefaultProducerContext>
source§fn from_config(
config: &ClientConfig,
) -> KafkaResult<ThreadedProducer<DefaultProducerContext>>
fn from_config( config: &ClientConfig, ) -> KafkaResult<ThreadedProducer<DefaultProducerContext>>
Creates a client from a client configuration. The default client context
will be used.
source§impl<C> FromClientConfigAndContext<C> for ThreadedProducer<C>where
C: ProducerContext + 'static,
impl<C> FromClientConfigAndContext<C> for ThreadedProducer<C>where
C: ProducerContext + 'static,
source§fn from_config_and_context(
config: &ClientConfig,
context: C,
) -> KafkaResult<ThreadedProducer<C>>
fn from_config_and_context( config: &ClientConfig, context: C, ) -> KafkaResult<ThreadedProducer<C>>
Creates a client from a client configuration and a client context.
source§impl<C> Producer<C> for ThreadedProducer<C>where
C: ProducerContext + 'static,
impl<C> Producer<C> for ThreadedProducer<C>where
C: ProducerContext + 'static,
source§fn flush<T: Into<Timeout>>(&self, timeout: T) -> KafkaResult<()>
fn flush<T: Into<Timeout>>(&self, timeout: T) -> KafkaResult<()>
Flushes any pending messages. Read more
source§fn in_flight_count(&self) -> i32
fn in_flight_count(&self) -> i32
Returns the number of messages that are either waiting to be sent or are
sent but are waiting to be acknowledged.
source§fn init_transactions<T: Into<Timeout>>(&self, timeout: T) -> KafkaResult<()>
fn init_transactions<T: Into<Timeout>>(&self, timeout: T) -> KafkaResult<()>
Enable sending transactions with this producer. Read more
source§fn begin_transaction(&self) -> KafkaResult<()>
fn begin_transaction(&self) -> KafkaResult<()>
Begins a new transaction. Read more
source§fn send_offsets_to_transaction<T: Into<Timeout>>(
&self,
offsets: &TopicPartitionList,
cgm: &ConsumerGroupMetadata,
timeout: T,
) -> KafkaResult<()>
fn send_offsets_to_transaction<T: Into<Timeout>>( &self, offsets: &TopicPartitionList, cgm: &ConsumerGroupMetadata, timeout: T, ) -> KafkaResult<()>
Associates an offset commit operation with this transaction. Read more
source§fn commit_transaction<T: Into<Timeout>>(&self, timeout: T) -> KafkaResult<()>
fn commit_transaction<T: Into<Timeout>>(&self, timeout: T) -> KafkaResult<()>
Commits the current transaction. Read more
source§fn abort_transaction<T: Into<Timeout>>(&self, timeout: T) -> KafkaResult<()>
fn abort_transaction<T: Into<Timeout>>(&self, timeout: T) -> KafkaResult<()>
Aborts the current transaction. Read more
source§fn context(&self) -> &Arc<C>
fn context(&self) -> &Arc<C>
Returns a reference to the
ProducerContext
used to create this
producer.Auto Trait Implementations§
impl<C> Freeze for ThreadedProducer<C>
impl<C> !RefUnwindSafe for ThreadedProducer<C>
impl<C> Send for ThreadedProducer<C>
impl<C> Sync for ThreadedProducer<C>
impl<C> Unpin for ThreadedProducer<C>
impl<C> !UnwindSafe for ThreadedProducer<C>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)