Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

程序关闭时,关掉kafka的连接, 不然运行long time任务的话,会出现需要等到group重新分配 #139

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion funboost/consumers/kafka_consumer_manually_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ def _shedual_task(self):
'sasl.password': BrokerConnConfig.KFFKA_SASL_CONFIG['sasl_plain_password'],
'group.id': self.consumer_params.broker_exclusive_config["group_id"],
'auto.offset.reset': self.consumer_params.broker_exclusive_config["auto_offset_reset"],
'enable.auto.commit': False
'enable.auto.commit': False,
"enable.auto.offset.store": False,
})
self._confluent_consumer.subscribe([self._queue_name])

Expand All @@ -170,3 +171,6 @@ def _shedual_task(self):
self.logger.debug(
f'从kafka的 [{self._queue_name}] 主题,分区 {msg.partition()} 中 的 offset {msg.offset()} 取出的消息是: {msg.value()}') # noqa
self._submit_task(kw)

def __exit__(self):
self._confluent_consumer.close()