Skip to content

Commit

Permalink
Fix: KafkaConsumer crashes with autoCommit=true (swift-server#102)
Browse files Browse the repository at this point in the history
Motivation:

Closes swift-server#99.

Modifications:

* `KafkaConsumer`: only subscribe to `RDKafkaEvent.offsetCommit` when
  `KakfaCOnsumerConfiguration.enableAutoCommit == false`
  • Loading branch information
felixschlegel authored Jul 27, 2023
1 parent f8cb0a0 commit 12020f5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Sources/SwiftKafka/KafkaConsumer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,16 @@ public final class KafkaConsumer: Sendable, Service {
self.config = config
self.logger = logger

var subscribedEvents: [RDKafkaEvent] = [.log, .fetch]
// Only listen to offset commit events when autoCommit is false
if self.config.enableAutoCommit == false {
subscribedEvents.append(.offsetCommit)
}

let client = try RDKafkaClient.makeClient(
type: .consumer,
configDictionary: config.dictionary,
events: [.log, .fetch, .offsetCommit],
events: subscribedEvents,
logger: logger
)

Expand Down

0 comments on commit 12020f5

Please sign in to comment.