rdkafka
Rust wrapper for librdkafka
0.39.0
35M downloads/mo
#1553 most downloaded on crates.io
fede1024/rust-rdkafka
What this package is like to depend on
Last release 7 months ago
25 Jan 2026
Release timing varies
gaps range from 3 weeks to 11 months
Most releases are documented
notes for 40 of 51 stable releases
1 version withdrawn
withdrawn after publishing
10 years old
52 releases · first in 2016
1 release in the last 12 months
see the full history below
Release timeline
52 releases · Oct 2016 to Jan 2026Releases
latest 52-
0.39.025 Jan 2026 -
0.38.005 Jul 2025Release notes
Open source →- Update
BaseProducer::pollto not return early, and instead continue looping until the passed timeout is reached. - Breaking change. Change signature for
OwnedDeliveryResult. TheOkvariant is now aDeliverystruct, rather than a tuple. This allows or includingTimestampas a result field. It means that adding values in the future will not require a breaking change. - Update
BaseProducer::flushto correctly callpollinternally, until all messages have been processed. - Upgrade all library dependencies.
- Add tests for Kafka versions up to 0.38.0.
- Require a minimum of CMake 3.5 compatibility for CMake build (#766)
- Update
-
0.37.025 Nov 2024Release notes
Open source →- Update MSRV to 1.70
- Fix test dependency on docker compose.
- Address wakeup races introduced by pivoting to the event API.
- Remove testing for old Kafka versions (before 3.0). Add tests for 3.7.
-
0.36.325 Nov 2024 withdrawnNothing published for this version
-
0.36.216 Jan 2024Release notes
Open source →- Update
BaseConsumer::pollto returnNonewhen handling rebalance or offset commit events.
- Update
-
0.36.111 Jan 2024Nothing published for this version
-
0.36.008 Nov 2023Release notes
Open source →- Pivot the library from using librdkafka's callback interface to using the event interface. The public API of the crate does not change.
-
0.35.007 Nov 2023Release notes
Open source →- Update bundled librdkafka to 2.3.0.
- Add cargo enforcement of MSRV of 1.61.
- Derives serde::Serialize on Statistics
-
0.34.025 Aug 2023 -
0.33.206 Jul 2023Release notes
Open source →- Breaking change. Change signature for
seek_partitions. Following librdkafka, individual partition errors should be reported in the per-partitionerrorfield ofTopicPartitionListelements.
- Breaking change. Change signature for
-
0.33.030 Jun 2023Release notes
Open source →- Add interface to specify custom partitioners by extending
ProducerContexttrait with capability to return optional custom partitioner. - Add
seek_partitionsto consumer.
- Add interface to specify custom partitioners by extending
-
0.32.209 Jun 2023Nothing published for this version
-
0.31.017 May 2023Release notes
Open source →- Breaking change. Pass
KafkaErrorto rebalance hooks instead of human-readable string representation.
- Breaking change. Pass
-
0.30.012 May 2023Release notes
Open source →-
Support for unassigning static partitions by passing
nulltordsys::rd_kafka_assignand expose the feature asunassigninbase_consumer -
Expose
rdsys::rd_kafka_incremental_assignandrdsys::rd_kafka_incremental_unassigninbase_consumerfor incremental changes to static assignments -
Breaking change.
util::get_rdkafka_versionnow returns(i32, String). Previously, it returned(u16, String)which would silently truncate the hex representation of the version:Interpreted as hex MM.mm.rr.xx:
MM = Major mm = minor rr = revision xx = pre-release id (0xff is the final release) E.g.: 0x010902ff = 1.9.2
-
Add the
AdminClient::delete_groupsmethod, which deletes consumer groups from a Kafka cluster (#510).Thanks, @andrewinci.
- Add support for the
purgeAPI, that allows retreiving messages that were queued for production when shutting down. It is automatically called onDrop. Fixes leaking associated data (futures...).
-
-
0.29.029 Oct 2022Release notes
Open source →-
Breaking change. Pass through errors from librdkafka in
BaseProducer::flush,StreamProducer::flush, andFutureProducer::flush.Thanks, @cjubb39.
-
Breaking change. Only provide
NaiveRuntimeif thenaive-runtimefeature is enabled. This elides a dependency onfutures-executorwhen thenaive-runtimefeature is disabled. -
Breaking change. Remove the deprecated
StreamConsumer::startmethod. Use the more clearly namedStreamConsumer::streammethod instead. -
Breaking change. Rework the
Headerstrait to distinguish between headers with null values and headers with empty values. TheHeaders::getandHeaders::get_asmethods now return aHeaderstruct with the following definition:pub struct Header<'a, V> { pub key: &'a str, pub value: Option<V>, }Previously, these methods operated in terms of key–value pair
(&str, &[u8]).These methods now panic if presented with an out-of-bounds index. This simplifies their usage in the common case where the index is known to be valid. Use the new
Headers::try_getandHeaders::try_get_asmethods if you need the old behavior of returningNoneif the index is invalid. -
Rename the
OwnedHeader::addmethod toOwnedHeader::insert, for parity with the equivalent method for the map types instd::collectionand to avoid confusion with theaddmethod of thestd::ops::Addtrait. The method now takes theHeadertype mentioned above as an argument, rather than the key and value as separate arguments. -
Add the
Headers::itermethod to iterate over all message headers in order. -
Add the
PartitionQueue::set_nonempty_callbackmethod to register a callback for a specific partition queue that will run when that queue becomes nonempty. This is a more flexible replacement for theConsumerContext::message_queue_nonempty_callbackmethod that was removed in the last release. -
In
BaseConsumer::rebalance_protocolandStreamConsumer::rebalance_protocol, handle null return values from the underlying librdkakfa API (#417). This avoids an occasional segfault in the rebalance callback.Thanks, @bruceg.
-
Add a
tracingfeature which, when enabled, emits log messages using thetracingcrate rather than thelogcrate. -
Add support for the
OAUTHBEARERSASL authentication mechanism via the newClientContext::ENABLE_REFRESH_OAUTH_TOKENconstant and the newClientContext::generate_oauth_tokenmethod.Thanks, @jsurany-bloomberg.
-
-
0.28.027 Nov 2021Release notes
Open source →-
Add the
StreamConsumer::split_partition_queuemethod to mirrorBaseConsumer::split_partition_queue(#411).Thanks to @davidblewett, @duarten, and @nemosupremo for contributing to the implementation.
-
Breaking change. Remove the
StreamConsumerContexttype and theConsumerContext::message_queue_nonempty_callbackmethod. These were essentially implementation details ofStreamConsumerthat had leaked into the public API. The vast majority of users should be unaffected. -
Breaking change. Remove the type parameters from the
MessageStreamtype. -
Breaking change. Add the received
TopicPartitionListto theRebalance::Revokevariant, which is useful when using incremental cooperative rebalancing (#398). -
Avoid crashing if librdkafka invokes the commit callback with a null topic partition list (#406).
Thanks, @thijsc.
-
Add the new statistics fields in librdkafka v1.7.0 to the various statistics types. The new fields are:
Partition::consumer_lag_storedBroker::txidleBroker::rxidleStatistics::age
-
Breaking change. Change the type of the following statistics fields from
i64tou64to reflect the signedness of the upstream types:Statistics::msg_cntStatistics::msg_sizeStatistics::msg_maxStatistics::msg_size_maxBroker::txBroker::txbytesBroker::txretriesBroker::req_timeoutsBroker::rxBroker::rxbytesBroker::rxerrsBroker::rxcorriderrsBroker::rxpartialBroker::zbuf_growBroker::buf_growBroker::wakeupsBroker::msgq_bytesBroker::xmit_msgq_bytesBroker::fetchq_sizePartition::txmsgsPartition::txbytesPartition::rxmsgsPartition::rxbytesPartition::msgsPartition::rx_ver_dropsPartition::acked_msgid
-
Add the
ClientContext::stats_rawmethod to consume the JSON-encoded statistics from librdkafka. The default implementation callsClientContext::statswith the decoded statistics. -
Add the
Defaulttrait to the statistics types:Statistics,Broker,Window,TopicPartition,Topic,Partition,ConsumerGroup, andExactlyOnceSemantics(#410).Thanks, @scanterog.
-
Add the
Debugtrait toDefaultClientContextandDefaultConsumerContext(#401).Thanks, @DXist.
<a name="0.27.0"></a>
-
-
0.27.018 Oct 2021Release notes
Open source →-
Allow offset 0 in
Offset::to_raw.Thanks, [@roignpar].
-
Fix a segfault when calling
Consumer::positionon a consumer that was improperly configured (#360). -
Provide a mutable accessor (
Message::payload_mut) for a message's payload (#95). -
Implement
std::iter::Extend<(String, String)>andstd::iter::FromIterator<(String, String)forClientConfig(#367).Thanks, @djKooks.
-
Breaking change. Change
Consumer::store_offsetto accept the topic, partition, and offset directly (#89, #368). The old API, which took aBorrowedMessage, is still accessible asConsumer::store_offset_from_message. -
Support incremental cooperative rebalancing (#364). There are two changes of note:
-
The addition of
Consumer::rebalance_protocolto determine the rebalance protocol in use. -
The modification of the default rebalance callback (
ConsumerContext::rebalance) to perform incremental assignments and unassignments when the rebalance protocol in use is [RebalanceProtocol::Cooperative].
Thanks, @SreeniIO.
-
-
Support reading and writing commit metadata via
TopicPartitionListElem::metadataandTopicPartitionListElem::set_metadata, respectively (#391).Thanks, @phaazon.
<a name="0.26.0"></a>
-
-
0.26.016 Mar 2021Release notes
Open source →-
Fix compilation for the aarch64 target.
-
Add an
innermethod toStreamConsumerContextto enable access to the underlying context.Thanks, @marcelo140.
-
Mark the
KafkaErrorenum as [non-exhaustive] so that future additions to the enum will not be considered breaking changes.
<a name="0.25.0"></a>
-
-
0.25.030 Jan 2021Release notes
Open source →-
Add support for transactional producers. The new methods are
Producer::init_transactions,Producer::begin_transaction,Producer::commit_transaction,Producer::abort_transaction, andProducer::send_offsets_to_transaction.Thanks to @roignpar for the implementation.
-
Breaking change. Rename
RDKafkaErrortoRDKafkaErrorCode. This makes space for the newRDKafkaErrortype, which mirrors therd_kafka_error_ttype added to librdkafka in v1.4.0.This change was made to reduce long-term confusion by ensuring the types in rust-rdkafka map to types in librdkafka as directly as possible. The maintainers apologize for the difficulty in upgrading through this change.
-
Breaking change. Rework the consumer APIs to fix several bugs and design warts:
-
Rename
StreamConsumer::starttoStreamConsumer::stream, though the former name will be retained as a deprecated alias for one release to ease the transition. The new name better reflects that the method is a cheap operation that can be called repeatedly and in multiple threads simultaneously. -
Remove the
StreamConsumer::start_withandStreamConsumer::start_with_runtimemethods.There is no replacement in rust-rdkafka itself for the
no_message_errorparameter. If you need this message, use a downstream combinator liketokio_stream::StreamExt::timeout.There is no longer a need for the
poll_intervalparameter to these methods. Message delivery is now entirely event driven, so no time-based polling occurs.To specify an
AsyncRuntimebesides the default, specify the desired runtime type as the newRparameter ofStreamConsumerwhen you create it. -
Remove the
Consumer::get_base_consumermethod, as accessing theBaseConsumerthat underlied aStreamConsumerwas dangerous. -
Return an
&Arc<C>fromClient::contextrather than an&C. This is expected to cause very little breakage in practice. -
Move the
BaseConsumer::contextmethod to theConsumertrait, so that it is available when using theStreamConsumeras well.
-
-
Breaking change. Rework the producer APIs to fix several design warts:
-
Remove the
FutureProducer::send_with_runtimemethod. Use thesendmethod instead. TheAsyncRuntimeto use is determined by the newRtype parameter toFutureProducer, which you can specify when you create the producer.This change makes the
FutureProducermirror the redesignedStreamConsumer.This change should have no impact on users who use the default runtime.
-
Move the
producer::base_producer::{ProducerContext, DefaultProducerContext}types out of thebase_producermodule and into theproducermodule directly, to match theconsumermodule layout. -
Move the
client,in_flight_count, andflushmethods inherent to all producers to a newProducertrait. This trait is analogous to theConsumertrait.
-
-
Breaking change. Calls to
BaseConsumer::assigndeactivate any partition queues previously created withBaseConsumer::split_partition_queue. You will need to re-split all partition queues after every call toassign.This is due to an upstream change in librdkafka. See edenhill/librdkafka#3231 for details.
-
Breaking change. Several
TopicPartitionList-related methods now returnResult<T, KafkaError>rather thanT:TopicPartitionListElem::set_offsetTopicPartitionList::from_topic_mapTopicPartitionList::add_partition_offsetTopicPartitionList::set_all_offsets
This was necessary to properly throw errors when an
Offsetpassed to one of these methods is representable in Rust but not in C. -
Support end-relative offsets via
Offset::OffsetTail. -
Fix stalls when using multiple
MessageStreams simultaneously.Thanks to @Marwes for discovering the issue and contributing the initial fix.
-
Add a convenience method,
StreamConsumer::recv, to yield the next message from a stream.Thanks again to @Marwes.
-
Add a new implementation of
AsyncRuntimecalledNaiveRuntimethat does not depend on Tokio.This runtime has poor performance, but is necessary to make the crate compile when the
tokiofeature is disabled. -
Add the
ClientConfig::getandClientConfig::removemethods to retrieve and remove configuration parameters that were set withClientConfig::set. -
Breaking change. Change the
keyandvalueparameters of theClientConfig::setmethod to accept any type that implementsInto<String>, rather than only&str.This is technically a breaking change as values of type
&&strare no longer accepted, but this is expected to be a rare case.Thanks, @koushiro.
-
Add the
NativeClientConfig::getmethod, which reflects librdkafka's view of a parameter value. UnlikeClientConfig::get, this method is capable of surfacing librdkafka's default value for a parameter. -
Add the missing
reqfield, which counts the number of requests of each type that librdkafka has sent, to theStatisticsstruct. Thanks, @pablosichert!
<a name="0.24.0"></a>
-
-
0.24.009 Jul 2020Release notes
Open source →-
Breaking change. Introduce a dependency on Tokio for the
StreamConsumerin its default configuration. The new implementation is more efficient and does not require a background thread and an extra futures executor. -
Introduce the
StreamConsumer::start_with_runtimeandFutureProducer::send_with_runtimemethods. These methods are identical to their respective non-_with_runtimecounterparts, except that they take an additionalAsyncRuntimegeneric parameter that permits using an asynchronous runtime besides Tokio.For an example of using rdkafka with the smol runtime, see the new smol runtime example.
-
Breaking change. Remove the
StreamConsumer::stopmethod. To stop aStreamConsumerafter callingstart, simply drop the resultingMessageStream. -
Breaking change. Overhaul the
FutureProducer::sendmethod. The old implementation incorrectly blocked asynchronous tasks withstd::thread::sleepand theblock_msparameter did not behave as documented.The new implementation:
-
changes the
block_ms: i64parameter toqueue_timeout: impl Into<Timeout>, to better match how timeouts are handled elsewhere in the rust-rdkafka API, -
depends on Tokio, in order to retry enqueuing after a time interval without using
std::thread::sleep, -
returns an opaque future that borrows its input, rather than a
DeliveryFuturewith no internal references, -
simplifies the output type of the returned future from
Result<OwnedDeliveryResult, oneshot::Canceled>toOwnedDeliveryResult.
Thanks to @FSMaxB-dooshop for discovering the issue and contributing the initial fix.
-
-
Breaking change. Remove the
util::duration_to_millisfunction. This functionality has been available in the standard library asstd::time::Duration::as_millisfor over a year. -
Introduce the
BaseConsumer::split_partition_queuemethod to allow reading messages from partitions independently of one another. -
Implement
Clone,Copy, andDebugforCommitMode. -
Decouple versioning of rdkafka-sys from rdkafka. rdkafka-sys now has its own changelog and will follow SemVer conventions. (#211)
<a name="0.23.1"></a>
-
-
0.23.113 Jan 2020 -
0.23.010 Jan 2020Release notes
Open source →-
Upgrade to the async/await ecosystem, including
std::future::Future, v0.3 of the futures crate, and v0.2 of Tokio. The minimum supported Rust version is now Rust 1.39. Special thanks to @sd2k and @dbcfd. (#187)The main difference is that functions that previously returned
futures01::Future<Item = T, Error = E>now return:
std::future::Future<Output = Result<T, E>>In the special case when the error was
(), the new signature is further simplified to:std::future::Future<Output = T>Functions that return
future::Streams have had the analogous transformation applied. -
Implement
SendandSynconBorrowedMessage, so that holding a reference to aBorrowedMessageacross an await point is possible. (#190) -
Implement
SynconOwnedHeaders, which applies transitively toOwnedMessage, so that holding a reference to anOwnedMessageacross an await point is possible. (#203) -
Bump librdkafka to v1.3.0. (#202)
-
Change the signature of
ConsumerContext::commit_callbackso that the offsets are passed via a safeTopicPartitionListstruct, and not a raw*mut rdkafka_sys::RDKafkaPartitionListpointer. Thanks, @scrogson! (#198). -
Fix CMake build on Windows when debug information is enabled (#194).
<a name="0.22.0"></a>
-
-
0.22.109 Jul 2020Nothing published for this version
-
0.22.004 Dec 2019Release notes
Open source →- Add a client for Kafka's Admin API, which allows actions like creating and deleting Kafka topics and changing configuration parameters. (#122)
- Fix compliation on ARM, and ensure it stays fixed by adding an ARM builder to CI. (#134, #162)
- Stop automatically generating librdkafka bindings. Platform-independent bindings are now checked in to the repository. (#163)
- Move zstd compression support behind the
zstdfeature flag. (#163) - Remove build-time dependency on bindgen, clang, and libclang. (#163)
- Support
Consumer::pauseandConsumer::resume. (#167) - Expose the
message_queue_nonemptycallback, which allows clients to put their poll thread to sleep and be woken up when new data arrives. (#164) - Implement
IntoOpaqueforArc<T>. (#171) - Add
Consumer::seekmethod. (#172) - Support building with Microsoft Visual C++ (MSVC) on Windows. (#176)
- Bump librdkafka to v1.2.2. (#177)
- Run tests against multiple Kafka versions in CI. (#182)
- Standardize feature names. All feature names now use hyphens instead of underscores, as is conventional, though the old names remain for backwards compatibility. (#183)
- Optionalize libz via a new
libzfeature. The new feature is a default feature for backwards compatibility. (#183) - Better attempt to make build systems agree on what version of a dependency to compile and link against, and document this hazard. (#183)
<a name="0.21.0"></a>
-
0.21.026 Apr 2019Release notes
Open source →- Add librdkafka 1.0 support
- Automatically generate librdkafka bindings
- Use updated tokio version in asynchronous_processing example
<a name="0.20.0"></a>
-
0.20.025 Feb 2019Release notes
Open source →- Add FreeBSD support
- Add
offsets_for_timesmethod - Add
committed_offsetsmethod
<a name="0.19.0"></a>
-
0.19.006 Feb 2019 -
0.18.106 Feb 2019 -
0.18.018 Jan 2019 -
0.17.030 Jun 2018Release notes
Open source →- Add missing documentation warning.
- Add new experimental producer API. Instead of taking key, value and timestamp directly,
producers now get them in a
ProducerRecordwhich allows to specify optional arguments using the builder pattern. - Add message headers support.
- Upgrade tokio-core to tokio in async example, remove futures-cpupool.
MessageStreamis now Send and Sync
<a name="0.16.0"></a>
-
0.16.020 May 2018 -
0.15.015 Mar 2018Release notes
Open source →- Added iterator interface to the
BaseConsumer. - Change timeout to more rust-idiomatic
Option<Duration>. - Add
external_lz4feature to use external lz4 library instead of the one one built in librdkafka. Disable by default. - Mark all
from_ptrmethods as unsafe. - Remove
Timestamp::from_system_timeand implementFromtrait instead. - Rename
ContexttoClientContext. - Rename
Empty(...)ContexttoDefault(...)Context. - Use default type parameters for the context of
Client, producers and consumers withDefault(...)Contextset as the default one. - Increase default buffer size in
StreamConsumerfrom 0 to 10 to reduce context switching.
<a name="0.14.1"></a>
- Added iterator interface to the
-
0.14.130 Dec 2017Release notes
Open source →- Upgrade to librdkafka 0.11.3
- Add
send_copy_resultmethod toFutureProducer
<a name="0.14.0"></a>
-
0.14.026 Nov 2017Release notes
Open source →Features
- Make
PollingProducermethods public - Rename
PollingProducertoThreadedProducer
Refactoring
- Remove
TopicConfigsince librdkafka supports default topic configuration directly in the top level configuration - Rename
DeliveryContextintoDeliveryOpaque - Add
IntoOpaquetrait to support different opaque types.
Bugs
- Fix regression in producer error reporting (#65)
<a name="0.13.0"></a>
- Make
-
0.13.022 Oct 2017Release notes
Open source →Refactoring
- Split producer.rs into multiple files
- Both producers now return the original message after failure
- BaseConsumer returns an Option<Result> instead of Result<Option>
Features
- Upgrade to librdkafka 0.11.1
- Enable dynamic linking via feature
- Refactor BaseConsumer, which now implements the Consumer trait directly
- A negative timestamp will now automatically be reported as NonAvailable timestamp
- Point rdkafka-sys to latest librdkafka master branch
- Add producer.flush and producer.in_flight_count
- Add max block time for FutureProducer
Bugs
- Fix memory leak during consumer error reporting
- Fix memory leak during producer error reporting
<a name="0.12.0"></a>
-
0.12.024 Jul 2017Release notes
Open source →Features
- Upgrade librdkafka to 0.11.0.
FutureProducer::send_copywill now return aDeliveryFuturedirecly.- TPL entries now also export errors.
KafkaErroris now Clone and Eq.
Bugs
- Fix flaky tests.
<a name="0.11.1"></a>
-
0.11.125 Jun 2017Release notes
Open source →Features
- Support direct creation of OwnedMessages.
<a name="0.11.0"></a>
-
0.11.020 Jun 2017Release notes
Open source →Features
- The topic partition list object from librdkafka is now completely accessible from Rust.
- The test suite will now run both unit tests and integration tests in valgrind, and it will also check for memory leaks.
- rdkafka-sys will use the system librdkafka if it's already installed.
- rdkafka-sys will verify that the crate version corresponds to the librdkafka version during the build.
- Timestamp is now Copy.
- Message has been renamed to BorrowedMessage. Borrowed messages can be transformed into owned messages. Both implement the new Message trait.
- Improved error enumerations.
Bugs
- Fix memory access bug in statistics callback.
- Fix memory leak in topic partition list.
- Messages lifetime is now explicit (issue #48)
<a name="0.10.0"></a>
-
0.10.014 May 2017Release notes
Open source →Features
- Consumer commit callback
- Add configurable poll timeout
- Add special error code for message not received within poll time
- Add topic field for messages
- Make the topic partition list optional for consumer commit
- Add
store_offsetto consumer - Add at-least-once delivery example
<a name="0.9.1"></a>
-
0.9.119 Apr 2017Release notes
Open source →Features
- OpenSSL dependency optional
- librdkafka 0.9.5
<a name="0.9.0"></a>
-
0.9.016 Apr 2017Release notes
Open source →Bugs
- Fix termination sequence
Features
- Integration tests running in docker and valgrind
- Producer topics are not needed anymore
<a name="0.8.1"></a>
-
0.8.121 Mar 2017Release notes
Open source →Bugs
- Implement Clone for
BaseProducerTopic
Features
<a name="0.8.0"></a>
- Implement Clone for
-
0.8.020 Mar 2017Release notes
Open source →Features
- Add timestamp support
- librdkafka 0.9.4
- Add client statistics callback and parsing
<a name="0.7.0"></a>
-
0.7.018 Feb 2017Release notes
Open source →Features
- Asynchronous message processing example based on tokio
- More metadata for consumers
- Watermark API
- First iteration of integration test suite
-
0.6.027 Dec 2016Nothing published for this version
-
0.5.011 Dec 2016Nothing published for this version
-
0.4.004 Dec 2016Nothing published for this version
-
0.3.026 Nov 2016Nothing published for this version
-
0.2.020 Nov 2016Nothing published for this version
-
0.1.110 Nov 2016Nothing published for this version
-
0.1.008 Nov 2016Nothing published for this version
-
0.0.129 Oct 2016Nothing published for this version