Spark Streaming: Kafka group id not permitted in Spark Structured Streaming

前端 未结 2 1009
名媛妹妹
名媛妹妹 2021-01-19 04:22

I am writing a Spark structured streaming application in PySpark to read data from Kafka.

However, the current version of Spark is 2.1.0, which does not allow me to

2条回答
  •  隐瞒了意图╮
    2021-01-19 04:41

    KafkaUtils class will override the parameter value for "group.id". It will concat "spark-executor-" in from of the orginal group id.

    Below is the code from KafkaUtils where is doing this:

    // driver and executor should be in different consumer groups
        val originalGroupId = kafkaParams.get(ConsumerConfig.GROUP_ID_CONFIG)
        if (null == originalGroupId) {
          logError(s"${ConsumerConfig.GROUP_ID_CONFIG} is null, you should probably set it")
        }
        val groupId = "spark-executor-" + originalGroupId
        logWarning(s"overriding executor ${ConsumerConfig.GROUP_ID_CONFIG} to ${groupId}")
        kafkaParams.put(ConsumerConfig.GROUP_ID_CONFIG, groupId)
    

    We faced the same problem. Kafka was based on ACL with presets group id, so the only thing was to alter the group id in kafka configuration. Insead of our original group id we put "spark-executor-" + originalGroupId

提交回复
热议问题