diff --git a/lib/manageiq/messaging/kafka/client.rb b/lib/manageiq/messaging/kafka/client.rb index f99f78a..f35b1b6 100644 --- a/lib/manageiq/messaging/kafka/client.rb +++ b/lib/manageiq/messaging/kafka/client.rb @@ -56,6 +56,9 @@ def ack(ack_ref) end def close + @admin&.close + @admin = nil + @producer&.close @producer = nil @@ -65,7 +68,7 @@ def close # list all topics def topics - kafka_client.admin.metadata.topics.map { |topic| topic[:topic_name] } + admin.metadata.topics.map { |topic| topic[:topic_name] } end private diff --git a/lib/manageiq/messaging/kafka/common.rb b/lib/manageiq/messaging/kafka/common.rb index 24679e4..78f97a1 100644 --- a/lib/manageiq/messaging/kafka/common.rb +++ b/lib/manageiq/messaging/kafka/common.rb @@ -8,6 +8,10 @@ module Common private + def admin + @admin ||= kafka_client.admin + end + def producer @producer ||= kafka_client.producer end