如何使用Spring Boot配置文件禁用/启用Confluent KAFKA拦截器?

4

我正在编写一个使用Confluent KAFKA replicator的Spring Boot应用程序,以下是我的Spring Boot配置文件:

spring:
  kafka:
    consumer:
      properties:
        interceptor:
          classes: io.confluent.connect.replicator.offsets.ConsumerTimestampsInterceptor
        timestamp:
          producer:
            security:
              protocol: PLAINTEXT
            sasl:
              mechanism: NONE

我在低级别环境中没有Confluent KAFKA复制器,例如:Dev。因此,我想要一个标志/配置属性来禁用/启用上述Confluent KAFKA拦截器(ConsumerTimestampsInterceptor)。我该怎么做?类似于这样:

spring:
  kafka:
    consumer:
      properties:
        interceptor:
          enabled : false
1个回答

3

您应该能够为您的Spring应用程序创建一个开发配置文件(例如,application-dev.yaml),然后完全删除该属性。没有enabled布尔属性。

此外,由于消费者属性是平面的,因此您不需要完全嵌套。

spring:
  kafka:
    consumer:
      properties:
        interceptor.classes: "className" 

我在开发环境中没有Confluent KAFKA复制器。如果我将这些属性保留在application-dev.yaml文件中并在开发环境中部署它,是否会引起任何问题? - One Developer
1
我不确定我理解这个问题。Replicator是Kafka Connect进程,它不是你作为Spring应用程序的一部分使用的东西。我从未使用过那些拦截器,但我认为“要求”Replicator运行,他们只是报告信息以进行Control Center延迟收集。 - OneCricketeer

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接