简体   繁体   English

气流:从 Kafka 获取消息

[英]Airflow: get messages from Kafka

I try get messages from Kafka in Airflow with python-kafka package.我尝试使用python-kafka包从 Airflow 中的 Kafka 获取消息。 Just in Python script it works.只是在 Python 脚本中它的工作原理。 But in Airflow I have this messages from Kafka Consumer.但是在 Airflow 中,我收到了来自 Kafka Consumer 的消息。 And don't have messages from Kafka.并且没有来自 Kafka 的消息。

[2020-09-07 17:51:08,046] {logging_mixin.py:112} INFO - [2020-09-07 17:51:08,046] {parser.py:166} DEBUG - Processing response MetadataResponse_v1
[2020-09-07 17:51:08,047] {logging_mixin.py:112} INFO - [2020-09-07 17:51:08,047] {conn.py:1071} DEBUG - <BrokerConnection node_id=2 host=10.1.25.112:9092 <connected> [IPv4 ('10.1.25.112', 9092)]> Response 28 (55.747270584106445 ms): MetadataResponse_v1(brokers=[(node_id=2, host='10.1.25.112', port=9092, rack=None), (node_id=3, host='10.1.25.113', port=9092, rack=None), (node_id=1, host='10.1.25.111', port=9092, rack=None)], controller_id=1, topics=[(error_code=0, topic='dev.tracking.nifi.rmsp.monthly.flow.downloading', is_internal=False, partitions=[(error_code=0, partition=0, leader=3, replicas=[3], isr=[3])])])
[2020-09-07 17:51:08,048] {logging_mixin.py:112} INFO - [2020-09-07 17:51:08,047] {cluster.py:325} DEBUG - Updated cluster metadata to ClusterMetadata(brokers: 3, topics: 1, groups: 0)
[2020-09-07 17:51:08,048] {logging_mixin.py:112} INFO - [2020-09-07 17:51:08,048] {fetcher.py:296} DEBUG - Stale metadata was raised, and we now have an updated metadata. Rechecking partition existance
[2020-09-07 17:51:08,048] {logging_mixin.py:112} INFO - [2020-09-07 17:51:08,048] {fetcher.py:299} DEBUG - Removed partition TopicPartition(topic='dev.tracking.nifi.rmsp.monthly.flow.downloading', partition=(0,)) from offsets retrieval
[2020-09-07 17:51:08,049] {logging_mixin.py:112} INFO - [2020-09-07 17:51:08,048] {fetcher.py:247} DEBUG - Could not find offset for partition TopicPartition(topic='dev.tracking.nifi.rmsp.monthly.flow.downloading', partition=(0,)) since it is probably deleted
[2020-09-07 17:51:08,107] {logging_mixin.py:112} INFO - [2020-09-07 17:51:08,107] {group.py:453} DEBUG - Closing the KafkaConsumer.

This error occurs when calling调用时出现此错误

        # Issue #1780
        # Recheck partition existence after after a successful metadata refresh
        if refresh_future.succeeded() and isinstance(future.exception, Errors.StaleMetadata):
            log.debug("Stale metadata was raised, and we now have an updated metadata. Rechecking partition existance")
            unknown_partition = future.exception.args[0]  # TopicPartition from StaleMetadata
            if self._client.cluster.leader_for_partition(unknown_partition) is None:
                log.debug("Removed partition %s from offsets retrieval" % (unknown_partition, ))
                timestamps.pop(unknown_partition)

Why I can't get topic leader?为什么我找不到话题负责人?


I think you need to provide some more info on your problem / set up. 我认为您需要提供有关您的问题/设置的更多信息。 we cannot see the set up, for example are you using docker for Airflow? 我们看不到设置,例如您是否使用 docker for Airflow? and local machine for Kafka? 和本地机器卡夫卡?
Then some people might be able to help you out. 那么有些人可能会帮助你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM