quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.63k stars 2.64k forks source link

kafka.bootstrap.servers not properly propagated? #8949

Closed Meemaw closed 4 years ago

Meemaw commented 4 years ago

Describe the bug It seems that kafka.bootstrap.servers is not properly propagated to the underlying systems? I'm trying to configure it through application.properties. On service startup I can see a log confirming that this is happening (kafka:9092):

{"timestamp":"2020-04-29T10:30:15.807Z","sequence":1083,"loggerClassName":"org.jboss.slf4j.JBossLoggerAdapter","loggerName":"io.smallrye.reactive.messaging.kafka.impl.KafkaSink","level":"INFO","message":"Setting bootstrap.servers to kafka:9092","threadName":"main","threadId":1,"mdc":{},"ndc":"","hostName":"4a4008aab27a","processName":"service-runner.jar","processId":1}

However later I can see logs like this (localhost/127.0.0.1:9092). Those start appearing after trying to send messages to @Channel through org.eclipse.microprofile.reactive.messaging.Emitter:

{"timestamp":"2020-04-29T10:31:14.455Z","sequence":2035,"loggerClassName":"org.apache.kafka.common.utils.LogContext$LocationAwareKafkaLogger","loggerName":"org.apache.kafka.clients.NetworkClient","level":"WARN","message":"[Producer clientId=producer-2] Connection to node 0 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.","threadName":"kafka-producer-network-thread | producer-2","threadId":19,"mdc":{},"ndc":"","hostName":"4a4008aab27a","processName":"service-runner.jar","processId":1}

Expected behavior kafka.bootstrap.servers should get properly propagated.

Configuration

## HTTP configuration
quarkus.http.port=8080
%dev.quarkus.http.port=8082
%test.quarkus.http.host=localhost

## OpenAPI configuration
quarkus.smallrye-openapi.path=/openapi

## Cors configuration
quarkus.http.cors=true
quarkus.http.cors.origins=http://localhost:3000,http://localhost:5000

## Datasource configuration
quarkus.datasource.username=${POSTGRES_USER:postgres}
quarkus.datasource.password=${POSTGRES_PASSWORD:postgres}
quarkus.datasource.url=vertx-reactive:postgresql://${POSTGRES_HOST:localhost}/${POSTGRES_DB:postgres}

## Logging configuration
%dev.quarkus.log.console.json=false
%test.quarkus.log.console.json=false

## Kafka configuration
kafka.bootstrap.servers=${KAFKA_BOOTSTRAP_SERVERS:localhost:9092}

mp.messaging.incoming.events.connector=smallrye-kafka
mp.messaging.incoming.events.value.deserializer=com.meemaw.events.model.external.serialization.BrowserEventDeserializer

## Service discovery
service.auth.host=localhost
service.auth.port=8080

Screenshots (If applicable, add screenshots to help explain your problem.)

Environment (please complete the following information):

cescoffier commented 4 years ago

Sorry for the very long delay. I believe the issue has been fixed and we forgot to close this issue.

Below is the list of what I've successfully tried. I ran my Kafka broker on localhost:9093 (while the default is localhost:9092). My application.properties contains:

kafka.bootstrap.servers=${KAFKA_BOOTSTRAP_SERVERS:localhost:9092}
  1. Setting the KAFKA_BOOTSTRAP_SERVERS to localhost:9093 and running the application from the jar file -> the application connects to the broker (localhost:9093)
  2. Running the application using java -Dkafka.bootstrap.servers=localhost:9093 target/...-runner.jar -> the application connects to the broker (localhost:9093)
  3. Running the application using java target/...-runner.jar -> the application connects to the broker (localhost:9092), and fails because it's not running on this port
  4. Setting the KAFKA_BOOTSTRAP_SERVERS to localhost:9093 and running the application in dev mode -> the application connects to the broker (localhost:9093)
  5. Running the application in dev mode with mvn quarkus:dev -Dkafka.bootstrap.servers=localhost:9093 -> the application connects to the broker (localhost:9093)

If you still notice the issue, please re-open it.