提供了 kafka schema.registry.url 但不是已知配置
Posted
技术标签:
【中文标题】提供了 kafka schema.registry.url 但不是已知配置【英文标题】:kafka schema.registry.url was supplied but isn't a known config 【发布时间】:2021-03-01 00:49:48 【问题描述】:尝试使用模式注册表发布有关主题的 json 消息,但出现以下错误。以下春季启动方法..
提供了配置“schema.registry.url”,但不是已知配置
应用 yml 文件
server:
port: 9080
spring:
kafka:
properties:
bootstrap.servers: server1:8080
schema.registry.url: https://bctdsdg:8081/
producer:
key-serializer: org.apache.kafka.common.serialization.StringSerializer
value-serializer: JsonSerializer.class
ssl:
keystore-location: classpath:cert.jks
keystore-password: pwd
key-password: pwd
truststore-location: classpath:dev_cacerts.jks
truststore-password: pwd
kafka 配置
@Configuration
@EnableKafka
public class KafkaConfig
@Autowired
private KafkaProperties kafkaProperties;
@Bean
public Map<String, Object> producerConfigs()
Map<String, Object> props = new HashMap<>();
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaProperties.getBootstrapServers());
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer");
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, com.schemaregjson.serdes.JsonSerializer.class);
props.put("schema.registry.url", "https://bctdsdg:8081/");
props.putAll(kafkaProperties.getSsl().buildProperties());
props.putAll(kafkaProperties.getProperties());
return props;
@Bean
public ProducerFactory<String, User> producerFactory()
return new DefaultKafkaProducerFactory<>(producerConfigs());
@Bean
public KafkaTemplate<String, User> kafkaTemplate()
return new KafkaTemplate<>(producerFactory());
----------------------------------------------
@SpringBootApplication
public class SchemaregjsonApplication implements CommandLineRunner
public static void main(String[] args)
SpringApplication.run(SchemaregjsonApplication.class, args);
@Autowired
private JsonProducer jsonproducer;
User user = new User().withAge(34).withFirstname("Don").withLastname("Joe");
@Override
public void run(String... args) throws Exception
jsonproducer.send(user);
【问题讨论】:
该消息不是错误...您遇到了什么问题? 我无法在模式注册表主题上发布消息.. 2020-11-17 13:52:19.593 WARN 15836 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Bootstrap broker localhost:9094 (id: -2 rack: null) 断开了此消息进入日志 你给定的代码是server1:8080
,那么你从哪里得到localhost:9094?
【参考方案1】:
在生产者和消费者属性下配置架构注册表 url。
应用 yml 文件
spring:
kafka:
bootstrap.servers: server1:8080
producer:
key-serializer: org.apache.kafka.common.serialization.StringSerializer
value-serializer: JsonSerializer.class
properties:
schema.registry.url: http://localhost:8081
ssl:
keystore-location: classpath:cert.jks
keystore-password: pwd
key-password: pwd
truststore-location: classpath:dev_cacerts.jks
truststore-password: pwd
【讨论】:
无论我将schema.registry.url
放在哪里,我都会不断收到警告
我也遇到了同样的问题。我不认为 KafkaProducer 客户端将 schema.registry.url
理解为与 KafkaStreams
不同的属性以上是关于提供了 kafka schema.registry.url 但不是已知配置的主要内容,如果未能解决你的问题,请参考以下文章
为 Schema Registry 定义 Kerberos 主体名称
在 windows 中启动 Confluent Schema Registry