【问题标题】:Want to enter the hostname:9092 in BootStrap url(I have the hostname entry against the actual url in my host file windows) JAVA想要在 BootStrap url 中输入主机名:9092(我的主机文件窗口中有针对实际 url 的主机名条目)JAVA
【发布时间】:2020-04-19 20:58:49
【问题描述】:

想输入 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】:

错误不是说UnknownHostException

schema.registry.url需要一个协议,它的端口不是9092

http://subham-virtualbox:8081

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

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

【讨论】:

    猜你喜欢
    • 2014-03-04
    • 2016-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-18
    • 1970-01-01
    • 2022-08-19
    相关资源
    最近更新 更多