要在BootStrap url中输入主机名:9092(我在主机文件窗口中有对应于实际URL的主机名条目)JAVA

问题描述 投票:1回答:1

想输入subham-virtualbox:9092而不是172.16.6.86:9092作为我的bootstrapURL和schemaRegistryurl。

我的主机文件中有此条目需要解决

172.16.6.86 subham-virtualbox

尝试这样做,出现错误,

Exception in thread "main" org.apache.kafka.common.errors.SerializationException: Error serializing Avro message
Caused by: java.net.MalformedURLException: unknown protocol: subham-virtualbox
    at java.net.URL.<init>(URL.java:617)
    at java.net.URL.<init>(URL.java:507)
    at java.net.URL.<init>(URL.java:456)
    at io.confluent.kafka.schemaregistry.client.rest.RestService.sendHttpRequest(RestService.java:175)
    at io.confluent.kafka.schemaregistry.client.rest.RestService.httpRequest(RestService.java:256)
    at io.confluent.kafka.schemaregistry.client.rest.RestService.registerSchema(RestService.java:356)
    at io.confluent.kafka.schemaregistry.client.rest.RestService.registerSchema(RestService.java:348)
    at io.confluent.kafka.schemaregistry.client.rest.RestService.registerSchema(RestService.java:334)
    at io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient.registerAndGetId(CachedSchemaRegistryClient.java:168)
    at io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient.register(CachedSchemaRegistryClient.java:222)
    at io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient.register(CachedSchemaRegistryClient.java:198)
    at io.confluent.kafka.serializers.AbstractKafkaAvroSerializer.serializeImpl(AbstractKafkaAvroSerializer.java:70)
    at io.confluent.kafka.serializers.KafkaAvroSerializer.serialize(KafkaAvroSerializer.java:53)
    at org.apache.kafka.common.serialization.Serializer.serialize(Serializer.java:62)
    at org.apache.kafka.clients.producer.KafkaProducer.doSend(KafkaProducer.java:903)
    at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:865)
    at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:752)
    at com.github.meSubhamSaraf.AvroSerializerDemo.main(AvroSerializerDemo.java:58)
java apache-kafka kafka-producer-api confluent-schema-registry
1个回答
1
投票

错误不是说UnknownHostException

[schema.registry.url需要协议,并且端口不是9092

http://subham-virtualbox:8081

您的引导服务器可以是subham-virtualbox:9092

就个人而言,我建议将Docker与注册表的简单端口转发一起使用,而不是整个VM。否则,单击Vagrant works great并可以通过插件为您编辑主机文件

© www.soinside.com 2019 - 2024. All rights reserved.