Skip to content

Commit 0f6caf9

Browse files
committed
Disconnect after leaving the group
This commit removes an unnecessary reconnection after `Kafka::Consumer#stop` is called. `@cluster.disconnect` closes the connections to all brokers including the coordinator in spite of the fact that `@group.leave` requires a connection to the coordinator, so call `@cluster.disconnect` after `@group.leave`.
1 parent 1b2ed7c commit 0f6caf9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/kafka/consumer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ def subscribe(topic_or_regex, default_offset: nil, start_from_beginning: true, m
116116
def stop
117117
@running = false
118118
@fetcher.stop
119-
@cluster.disconnect
120119
end
121120

122121
# Pause processing of a specific topic partition.
@@ -433,6 +432,7 @@ def consumer_loop
433432
# important that members explicitly tell Kafka when they're leaving.
434433
make_final_offsets_commit!
435434
@group.leave rescue nil
435+
@cluster.disconnect
436436
@running = false
437437
@logger.pop_tags
438438
end

0 commit comments

Comments
 (0)