View Source KafkaEx Changelog
1.0.1 (2026-06-26)
Breaking Changes
KafkaEx.API.start_client/1no longer registers globally by default. Previouslystart_client()(no:nameargument) silently registered the GenServer asKafkaEx.Client, while the documented:nameoption was ignored. Two callers collided with:already_started.Now
start_client()returns{:ok, pid}unnamed. To preserve the old behavior explicitly:KafkaEx.API.start_client(name: KafkaEx.Client):nameaccepts anyGenServer.name()shape: an atom,{:global, term}, or{:via, Module, term}. See UPGRADING.md for the full migration. Most callers bind the returned pid ({:ok, client} = start_client(...)) and are unaffected.Consumer
auto_offset_resetnow defaults to:latest(was:none), matching the Kafka/Java client default, and:nonenow raises instead of silently starting a fresh consumer group from the earliest offset. This only affects a consumer with no valid committed offset that does not setauto_offset_resetexplicitly: a new consumer group now consumes only new messages (previously it silently replayed the whole topic), and an out-of-range offset now resets to latest (previously it raised). Setauto_offset_reset: :earliestto keep replaying from the beginning, or:nonefor the strict raise-on-bad-offset behavior. An invalid value now fails fast at consumer start. See UPGRADING.md.
Fixed
KafkaEx.API.start_client/1andchild_spec/1now mergeconfig.exsdefaults and accept the documented:brokersoption (#538). Previouslystart_client(brokers: [...])crashed withInvalidConsumerGroupError: nilbecause config defaults were never merged and the:brokerskey was ignored (the client read:uris).:brokersis now the canonical key;:urisis a deprecated-but-working alias.start_client/1returns{:error, :invalid_consumer_group}on a bad group;child_spec/1raisesKafkaEx.InvalidConsumerGroupErrorat spec-build time.KafkaEx.API.fetch/5(andKafkaEx.Consumer.Stream) hang at logend. Previously the GenServer.call default timeout (5s) and the per-brokerSocket.recvtimeout (1-3s fromsync_timeoutconfig) were not aligned with the user-supplied:max_wait_time(default 10s). The broker held the long-poll for up to 10s; both upper timeouts fired first, causingsocket close → reconnect → retry3 times, every retry hitting the same mismatch.Now
KafkaEx.API.fetch/5derives both timeouts from:max_wait_timeautomatically (network_timeout =max_wait_time + 5_000, call_timeout =network_timeout × 3 + 5_000). The× 3multiplier covers the Client's retry budget so the GenServer.call does not exit while retries are still in flight. Users who bumpedsync_timeoutas a workaround can revert.Two related stream bugs also fixed:
KafkaEx.Consumer.Streamno longer silently spins when a fetch returns an error andno_wait_at_logend: false. The stream halts and emits aLogger.warningwith the error code.auto_commit: true+ error response no longer raisesKeyErroronfetch_response.message_set.need_commit?/2returns false for error responses, so no commit is attempted.
KIP-394 two-step
JoinGroupno longer retries on:member_id_required(#541). The generic retry loop treated:member_id_requiredas a transient error and blindly re-sent the identical request, which the broker rejected again.JoinGroupnow uses a dedicatedKafkaEx.Support.Retry.join_group_retryable?/1classifier that returnsfalsefor:member_id_required, so the two-step path swaps in the broker-assignedmember_idand rejoins as KIP-394 intends. Required for correct interop with Kafka 2.3+ undergroup.initial.rebalance.delay.ms.Consumer-group heartbeat and SyncGroup errors now rejoin or stop cleanly instead of crashing the group (#554, #555). Previously
:illegal_generation/:unknown_member_id/:fenced_instance_idreached the manager as a generic error and crashed it under theone_for_all/max_restarts: 0consumer-group supervisor, escalating one member's stale generation into a group-wide rebalance. Now, matching brod's identity handling (terminal codes follow the Java client)::illegal_generation→ rejoin keepingmember_id(only the generation is stale).:unknown_member_id→ rejoin after clearingmember_id(the coordinator forgot the member; the broker assigns a fresh one).:fenced_instance_id(KIP-345) and:group_authorization_failed→ clean terminal stop without rejoining (rejoining would split-brain the static slot or fail authorization again).
Stale heartbeat-timer EXITs (from a timer already replaced during a rebalance) are dropped instead of acted on. A
{:heartbeat_rejoin, reason}reason is emitted on the[:kafka_ex, :consumer, :rebalance]telemetry event.Client retry loop preserves the real transport error atom (#544). A
recvtimeout to a broker was mapped to:unknown, which crashed the consumer-group manager viaSyncGroupError(the rebalance-storm root cause). The actual transport atom (:timeout,:closed, …) is now kept so it is classified and recovered correctly.Consumer-group sync recovery is bounded, not crash-on-error (#546). Recoverable
SyncGrouperrors now rejoin with a bounded retry budget and generation reset between attempts instead of raising and tearing down the group supervisor.The group coordinator is re-discovered on
:not_coordinator/:coordinator_not_available(#547). Previously a stale cached coordinator was reused after the coordinator moved (rolling restart), so every subsequent request failed. The cached coordinator is now invalidated and rediscovered.OffsetCommit / OffsetFetch correctness — no silent loss or duplicate processing (#548). The stream halts on a fatal commit error instead of looping and reprocessing;
load_offsetsretries retryable errors (including:unstable_offset_commit, KIP-447) and raises on fatal/exhaustion instead of silently resetting to the earliest offset.Broker connect is bounded by a timeout instead of blocking indefinitely (#556). Connecting to an unreachable broker no longer hangs the client; the connect is bounded by
:connect_timeout(default 10s).Transaction control batches are dropped from fetch results, and the fetch offset advances past them (#557). Control batches (transaction commit/abort markers) were surfaced to consumers as records; they are now filtered out. A fetch that contains only control batches still advances the consumer/stream offset past them (via the batch metadata) instead of re-fetching the same offset forever.
Internal
- Consumer-group / config test stabilization: eliminated the
on_exitteardown:noprocrace class viaKafkaEx.TestSupport.ProcessHelpersand stabilized three flaky consumer-group / config tests (#549, #553). load_offsetsstartup retry now rides the unifiedKafkaEx.Support.Retry.with_retry/2with exponential backoff (#551).- Renamed the
KafkaEx.Support.Retryoption:max_retriesto:max_attemptsfor consistency with the retry-count semantics (#552). - Migrated the test suite's mocking from Hammox to Mimic (
mimic ~> 1.7), dropping the unusedKafkaEx.NetworkClientMock. No runtime/production changes. (#534) - Added regression test coverage pinning previously-untested behavior:
remote-close (
:tcp_closed/:ssl_closed) handling and its telemetry inKafkaEx.Client(#449), init fail-fast when all brokers are unreachable (#298), and cross-topic response identity on a single client (#445). (#535)
1.0.0
Single release entry accumulates all post-rc.2 work. RC tags along the way (rc.3, rc.4, …) share this entry — individual rc entries are not maintained.
Breaking Changes
Produce headers API — the
headers:option onKafkaEx.API.produce/4,5,produce_one/4,5, andproduce_sync/4,5now requires[%KafkaEx.Messages.Header{}]structs instead of[{binary, binary}]tuples. Brings the produce path in line with the fetch path, which already returned%Header{}structs.Before:
KafkaEx.API.produce(client, "t", 0, [ %{value: "v", headers: [{"key", "val"}]} ])After:
alias KafkaEx.Messages.Header KafkaEx.API.produce(client, "t", 0, [ %{value: "v", headers: [Header.new("key", "val")]} ])Silent-at-compile, fails-at-runtime with
FunctionClauseError— see UPGRADING.md for the migration pattern.
Fixed
Consumer group no longer silently consumes on stale generation after a non-retryable
OffsetCommiterror. Previously:illegal_generation(and siblings) were logged and swallowed; the consumer kept running on a stale generation until the next heartbeat happened to also fail, potentially many seconds of zombie operation. Now classified across three paths matching JavaConsumerCoordinator, librdkafkardkafka_cgrp, brodbrod_group_coordinator, and kafka-python:- Terminal —
:fenced_instance_id(KIP-345),:group_authorization_failed,:topic_authorization_failed,:offset_metadata_too_large,:invalid_commit_offset_size. Consumer stops without rejoining. - Fatal —
:illegal_generation,:unknown_member_id. GenConsumer casts{:rejoin_required, reason, stale_gen}to the group manager (with mailbox coalescing for multi-partition storms), self-stops with{:shutdown, {:rejoin_required, _}}. Manager resets member_id / generation_id and rebalances. Underrestart: :transientthe supervisor does not respawn the stopped worker; the rebalance spawns a fresh one. - Retryable —
:rebalance_in_progress(flag-and-wait; heartbeat path drives the eventual rebalance, matching Java),:unstable_offset_commit(KIP-447), and standard transient errors.
At-least-once semantics preserved. See UPGRADING.md for details.
- Terminal —
Bootstrap crash when
api_versionwas set explicitly and the broker map was empty — the client now honors the explicit override instead of returning:api_not_supported_by_broker.Record-header encoding in V3+ record batches (per-record headers were previously dropped).
Version-0 falsy bug in
get_api_version— V0 was treated as "unset" and fell through to the hardcoded default.
Added
KIP-394 two-step JoinGroup. Client auto-retries
JoinGroupwith the broker-assignedmember_idon:member_id_required. Required for interop with Kafka 2.3+ undergroup.initial.rebalance.delay.ms.KIP-345 batch LeaveGroup V3+.
LeaveGroupsends themembersarray for V3+ brokers.3-tier API version resolution.
- Per-request
:api_versionoption - Application config
api_versions: %{...}map - Broker-negotiated max (
min(broker_max, kayrock_max))
Replaces hardcoded defaults that ignored broker capability. Previously produce/fetch used v3 regardless of what the broker supported; now a Kafka 3.x broker will get the full API surface.
- Per-request
KafkaEx.Support.VersionHelper.maybe_put_api_version/3— internal helper for consumer/stream callers. Thin wrapper over the 3-tier resolution.[:kafka_ex, :consumer, :commit_failed]telemetry event. Emitted on every commit-error branch (terminal / fatal / transient) with metadata%{group_id, topic, partition, offset, kind, error}. Parity stand-in for Java'sCommitFailedException— subscribe to the event to observe commit failures.Retry classifiers.
KafkaEx.Support.Retry.commit_fatal_error?/1andcommit_terminal_error?/1— mirrors the reference-client error taxonomy.
Changed
Test infrastructure.
Process.sleep(50)replaced withMockClient.wait_for_calls/3polling helper for deterministic unit tests. Adds lifecycle integration tests for the 3-tier version resolution and the:illegal_generationrejoin loop.Integration + chaos coverage for Phase B. Live-broker integration tests for rejoin_required cast handling, plus a Testcontainers-isolated chaos test that fires a 30-second storm of fatal casts and asserts the mailbox-drain coalescing ratio.
Removed
:consumer_group_update_intervalconfig option (and correspondingClient.Statefield). The value was silent-ignored long before 1.0; removed to clean up the config surface. No runtime impact — consumer-group polling cadence is driven by heartbeat/session-timeout, which remain configurable.
Migration
See UPGRADING.md.
1.0.0-rc.2 - 2026-03-15
Fixed
ConsumerGroupDescription.Member.member_assignmentnow returns an empty%MemberAssignment{version: 0, user_data: <<>>, partition_assignments: []}struct instead ofnilwhen Kafka returns a null or empty member assignment (e.g., during rebalancing). This preventsKeyErrorcrashes when accessing.partition_assignmentson the result. Breaking: code that pattern-matches onmember_assignment: nilor checks== nilmust be updated to check for an emptypartition_assignmentslist instead.
Changed
MemberAssignmentdefstruct now has explicit defaults (version: 0,partition_assignments: [],user_data: <<>>) matching its typespec.- Type specs for
Member.t()andMember.assignment/1no longer include| nilfor themember_assignmentfield.
1.0.0-rc.1 - 2026-02-15
Breaking Changes
- Removed legacy server implementations (Server0P8P0, Server0P8P2, Server0P9P0, Server0P10AndLater)
- Removed
kafka_versionconfiguration option - Kayrock is now the only implementation - Kayrock is now the default and only client implementation
- Module reorganization:
KafkaEx.GenConsumer→KafkaEx.Consumer.GenConsumerKafkaEx.ConsumerGroup→KafkaEx.Consumer.ConsumerGroupKafkaEx.New.Kafka.*→KafkaEx.Messages.*KafkaEx.New.Client→KafkaEx.ClientKafkaEx.New.KafkaExAPI→KafkaEx.API
Added
KafkaEx.APImodule as primary API with explicit client-based functions- Automatic API version negotiation with Kafka brokers
- Full message headers support
- SASL authentication support (PLAIN, SCRAM-SHA-256, SCRAM-SHA-512, OAUTHBEARER, MSK_IAM)
- Telemetry support for request lifecycle monitoring and observability
- Heartbeat API (v0-v4) with full version support
- LeaveGroup API (v0-v4) with full version support
- SyncGroup API (v0-v4) with full version support
- Graceful shutdown for GenConsumer
- Compression support (gzip, snappy, lz4, zstd)
Changed
- All functions now use Kayrock for protocol handling
- Improved error handling with structured errors (
KafkaEx.Client.Error) - Codebase reorganized by domain (cluster, client, consumer, producer, messages)
- Test structure reorganized to match new module organization
Removed
- Legacy
KafkaEx.produce/4andKafkaEx.fetch/3- useKafkaEx.APIfunctions KafkaEx.Server0P8P0,KafkaEx.Server0P8P2,KafkaEx.Server0P9P0,KafkaEx.Server0P10AndLaterkafka_versionconfiguration option- Legacy snappy-erlang-nif dependency (snappyer is now the default)
Migration
See UPGRADING.md for detailed migration instructions.
0.14
Fixes
- Multiple Github Action Fixes
- Fix deprecation warnings with Bitwise usage
- Fix deprecation warnings with Config
- Fix deprecation warnings with Stacktrace
Features
- Added
describe_groupsAPI
Breaking Changes
- Set minimal version of elixir to 1.8
0.13
- Support Snappyer 2
- Continuous integration: replace CircleCI
- Using the Kayrock client: take into account the
api_versionwhen retrieving offsets to fetch messages. - Update metadata before topic creation to make sure it connects to a controller broker.
- Support record headers.
0.12.1
Increases the version of ex_doc to allow publishing
Includes all the 0.12.0 changes.
0.12.0
NOTE: not released due to issues with ex_doc.
Breaking Changes
- Drop support for Elixir 1.5
Features
- Allow passthrough of ssl_options when starting a consumer or consumer group (#413)
- Allow GenConsumer callbacks to return
:stop- allows graceful shutdown of consumers (#424)
Bugfixes
Misc
- Use Dynamic Supervisor rather than simple_one_for_one - fixes warnings on newer elixir versions (#418)
- Update to Kayrock 0.1.12 - fix compile warnings (#419)
- Tests pass the first time more often now (#420)
- Fix deprecation warning about
Supervisor.terminate_child(#430) - Remove Coveralls - was not being used, caused test failures (#423)
PRs Included
- #413
- #418
- #419
- #420
- #430
- #423
- #424
0.11.0
KafkaEx 0.11.0 is a large improvement to KafkaEx that sees the introduction of the Kayrock client, numerous stability fixes, and a critical fix that eliminates double-consuming messages when experiencing network failures under load.
Breaking changes
- Drop support for Elixir < 1.5
- Partitioner has been fixed to match the behavior of the Java client. This will cause key assignment to differ. To keep the old behavior, use the KafkaEx.LegacyPartitioner module. (#399)
Fixes
- Numerous fixes to error handling especially for networking connections (#347, #351 )
- Metadata is refreshed after topic create/delete(#349)
- Compression actually works for producing now 😬 (#362)
- Don't crash when throttled by quotas (#402)
- Default partitioner works the same way as the Java client now (#399)
- When fetching metadata for a subset of topics, don't remove the metadata for the unfetched topics. (#409)
Improvements
- Any GenServer can be used as a KafkaEx.GenConsumer (#339)
- Can specify wait time before attempting reconnect (#347)
- KafkaEx.stream/3 now uses the KafkaEx.Server interface, which inherits the sync_timeout setting. This avoids timeouts when sync_timeout needs to be greater than default. (#354)
- KafkaEx can now use Kayrock as the client implementation. This is a large change, and is pushing toward the improvements we want in 1.0 to allow the library to easily support new versions of the Kafka protocol. (#356, #359, #364, #366, #367, #369, #370, #374, #375, #377, #379, #387, #406, #408)
-
KafkaEx.Protocol.Fetch.Messageincludes the topic and partition, allowing consumers to know which topic and partition they consumed from. - Add
KafkaEx.start_link_worker/1-2to start a working and link it to the current process. - Allow setting the client_id for the application - supports better monitoring, debugging, and quotas. (#388)
- Send metadata requests to a random broker rather than the same one each time (#395)
- Retry joining a consumer group 6 times rather than failing (#375, #403)
Kayrock client
See Kayrock and the Future of KafkaEx
Note that the Kayrock implementation doesn't support Kafka < 0.11
Improvements over default client:
- Can specify message API versions for the
KafkaEx.stream/3API - Can specify message API versions for the consumer group API - NOTE that if you specify OffsetCommit API version >= 2, it will attempt to store the offsets in kafka, which will have no data about the topic unless you migrate the data. This could result in losing or reprocessing data. Migration can be done out of band, or can be done via the appropriate API calls within KafkaEx.
- Allow specifying OffsetCommit API version in KafkaEx.fetch
Misc
- Test suite uses KafkaEx 0.11 now in preparation for fully supporting Kafka API versions.
- KafkaEx.Protocol.Produce cleaned up (#380)
- Documentation improvements (#383, #384)
- Test against Elixir 1.9 (#394)
- Use OTP 22.3.3+ for OTP 22.2 testing to avoid SSL bug. (#405)
0.10.0
Features
- Allow passing in state to a
KafkaEx.GenConsumerby defining aKafkaEx.GenConsumer.init/3callback. Adds a default implementation ofinit/3to ensure backward compatibility. -- @mtrudel - Support DeleteTopics API for Kafka 0.10+ -- @jbruggem
- Add a default partitioner using murmur2 hashing when key is provided, or random partitioning otherwise. Use the
KafkaEx.Partitionerbehaviour to define a different partitioner, and enable it by adding it to thepartitionerconfiguration setting.
Misc
- Lots of documentation fixes
- Fixing elixir 1.8 compile warnings
PRs Included:
- #343
- #338
- #337
- #335
- #329
- #333
- #331
Previous Versions
See the releases for change notes.