我们可以使用 org.apache.kafka.clients.producer.ProducerConfig 设置生产者配置 'delivery.timeout.ms'

Can we set the producer configuratoin 'delivery.timeout.ms' using org.apache.kafka.clients.producer.ProducerConfig

我们正在使用 spring-kafka-2.2.7.RELEASE 来生成和使用 avro 消息,并使用模式注册表以 'FORWARD_TRANSITIVE' 作为兼容性类型进行模式验证。现在,我试图了解是否可以选择为生产者配置设置自定义值 'delivery.timeout.ms'?

如果您没有使用 Spring 引导,您可以简单地在用于创建生产者工厂的生产者配置映射中设置 属性。

如果您正在使用Spring引导(请添加 tag in future), see the Boot documentation about spring-kafka integration

The properties supported by auto configuration are shown in appendix-application-properties.html. Note that, for the most part, these properties (hyphenated or camelCase) map directly to the Apache Kafka dotted properties. Refer to the Apache Kafka documentation for details.

The first few of these properties apply to all components (producers, consumers, admins, and streams) but can be specified at the component level if you wish to use different values. Apache Kafka designates properties with an importance of HIGH, MEDIUM, or LOW. Spring Boot auto-configuration supports all HIGH importance properties, some selected MEDIUM and LOW properties, and any properties that do not have a default value.

Only a subset of the properties supported by Kafka are available directly through the KafkaProperties class. If you wish to configure the producer or consumer with additional properties that are not directly supported, use the following properties:

spring.kafka.properties.prop.one=first
spring.kafka.admin.properties.prop.two=second
spring.kafka.consumer.properties.prop.three=third
spring.kafka.producer.properties.prop.four=fourth
spring.kafka.streams.properties.prop.five=fifth

This sets the common prop.one Kafka property to first (applies to producers, consumers and admins), the prop.two admin property to second, the prop.three consumer property to third, the prop.four producer property to fourth and the prop.five streams property to fifth.