Principle:Fede1024 Rust rdkafka Non Blocking Message Production
| Knowledge Sources | |
|---|---|
| Domains | Messaging, Async_Programming |
| Last Updated | 2026-02-07 19:00 GMT |
Overview
A non-retrying message enqueue operation that immediately returns a delivery future or an error if the queue is full.
Description
Non-Blocking Message Production differs from the standard send() in that it does not retry when the producer's internal queue is full. Instead, it immediately returns either a DeliveryFuture (on successful enqueue) or the error and original record (on failure). This gives the caller full control over retry logic and backpressure handling.
This is useful in scenarios where you want to implement custom retry strategies, need immediate feedback on queue status, or are operating in test code where retries would mask issues.
Usage
Use send_result instead of send when you need immediate feedback on enqueue success without automatic retry. Common in testing scenarios and when implementing custom backpressure mechanisms.
Theoretical Basis
Pseudo-code logic:
// Abstract algorithm
match producer.send_result(record) {
Ok(delivery_future) => {
// Message enqueued, await delivery confirmation
let result = delivery_future.await;
}
Err((error, record)) => {
// Queue full or other error, handle immediately
// No automatic retry
}
}