eclipse-vertx / vert.x

Vert.x is a tool-kit for building reactive applications on the JVM
http://vertx.io
Other
14.32k stars 2.08k forks source link

AddressResolverOptions.addServer not showing in logs nor seeming to resolve addresses #2048

Closed junglie85 closed 6 years ago

junglie85 commented 7 years ago

I've a Launcher class which extends io.vertx.core.Launcher. In an overridden beforeStartingVertx(VertxOptions) method, I add a DNS address for a Consul server:

@Override
  public void beforeStartingVertx(VertxOptions options) {
    String consulDnsAddress = "127.0.0.1:8600";
    logger.info("Adding consul DNS address: {}", consulDnsAddress);
    options.setAddressResolverOptions(
        new AddressResolverOptions()
            .addServer(consulDnsAddress)
    );
  }

My logs show this is being executed (well, the logging call is anyway!):

2017-07-11 21:49:47,545 755  [main] INFO  uk.ashleybye.microservice.Launcher - Adding consul DNS address: 127.0.0.1:8600

Yet the only DNS resolver entry I see is:

2017-07-11 21:49:47,682 892  [main] DEBUG i.n.resolver.dns.DnsServerAddresses - Default DNS servers: [/192.168.0.1:53, /fdf4:eff8:1c4e:0:7250:afff:fe04:6e78:53] (sun.net.dns.ResolverConfiguration)

If I try to set the location of a server, say a kafka bootstrap server using the vertx-kafka-client, like so (I've a wrapper around the options but if I specify the actual address of the server there is no issue):

options.setBootstrapServers("kafka.service.consul");
// Or http://kafka.service.consul"

Gives me the following exception:

2017-07-11 22:07:35,822 1743 [vert.x-eventloop-thread-0] ERROR u.a.m.m.i.BufferKafkaProducerService - Failed to initialise kafka producer
org.apache.kafka.common.KafkaException: Failed to construct kafka producer
    at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:342)
    at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:191)
    at io.vertx.kafka.client.producer.impl.KafkaWriteStreamImpl.create(KafkaWriteStreamImpl.java:44)
    at io.vertx.kafka.client.producer.KafkaWriteStream.create(KafkaWriteStream.java:51)
    at io.vertx.kafka.client.producer.KafkaProducer.create(KafkaProducer.java:147)
    at uk.ashleybye.microservice.messaging.impl.BufferKafkaProducerService.lambda$new$0(BufferKafkaProducerService.java:33)
    at uk.ashleybye.microservice.discovery.impl.ConsulServiceImpl.lambda$lookupService$0(ConsulServiceImpl.java:77)
    at io.vertx.ext.consul.impl.ConsulClientImpl.lambda$request$52(ConsulClientImpl.java:616)
    at io.vertx.ext.web.client.impl.HttpRequestImpl.lambda$null$1(HttpRequestImpl.java:238)
    at io.vertx.core.impl.ContextImpl.lambda$wrapTask$2(ContextImpl.java:337)
    at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:403)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:445)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.kafka.common.config.ConfigException: Invalid url in bootstrap.servers: messaging-service-kafka.service.consul

I have four questions disguised as two:

  1. Why is the DNS resolver that I added not showing up in the logs? Am I correctly adding it?
  2. Without getting into the kafka-client internals, is this the correct way to specify the address and can Vert.x deal with such addresses? Or do I need to format it differently?

Any help or clarification would be hugely appreciated.

vietj commented 7 years ago
  1. the log is the default server address, it does not mean the server address you add explicitly is not used. To be sure you can monitor the UDP traffic to see if the server is used.

  2. the kafka question seems rather related to be a kafka issue ? the dns server you configure are used for Vert.x and don't propagate to Kafka

junglie85 commented 7 years ago

Thanks re point 1.

Re point 2, it's more whether Vert.x is able to parse an address such as kafka.service.consul? I'm not trying to use Vert.x to propagate the DNS details to Kafka.

junglie85 commented 7 years ago

Following on from point 1 actually, would it be prudent for Vert.x to log any additional resolvers added, although it looks like that's probably a question for the Netty team?