将spark配置为使用此处公开的kafka时:
https://spark.apache.org/docs/latest/structured-streaming-kafka-integration.html#kafka-特定配置
spark声明如下:
“interceptor.classes:kafka源代码总是以字节数组的形式读取键和值。使用consumerinterceptor不安全,因为它可能会破坏查询。“
然后我在这里看到了https://github.com/apache/spark/blob/master/external/kafka-0-10-sql/src/main/scala/org/apache/spark/sql/kafka010/kafkasourceprovider.scala#l307
val otherUnsupportedConfigs = Seq(
ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, // committing correctly requires new APIs in Source
ConsumerConfig.INTERCEPTOR_CLASSES_CONFIG) // interceptors can modify payload, so not safe
otherUnsupportedConfigs.foreach { c =>
if (params.contains(s"kafka.$c")) {
throw new IllegalArgumentException(s"Kafka option '$c' is not supported")
}
}
是的,不安全,但当一个人知道他做什么,它可以安全地使用。因此,我想知道为什么阻止它的设计,如果有一个解决办法?
暂无答案!
目前还没有任何答案,快来回答吧!