I am using the gradle dependency io.smallrye.reactive:smallrye-mutiny-vertx-consul-client:3.11.0
in a Quarkus Web Service to register the service to the Consul service discovery.
Starting the service via IntelliJ Run configuration works successfully, but if I containerize the application using docker-compose and run docker compose up
, an io.smallrye.config.ConfigValidationException is thrown, indicating that some properties like quarkus.consul-config.apps-config.enabled
does not map to any root.
<code>2024-06-06 12:16:04 Jun 06, 2024 10:16:02 AM io.quarkus.config
2024-06-06 12:16:04 WARN: Unrecognized configuration key "quarkus.consul-config.apps-config.enabled" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2024-06-06 12:16:04 Jun 06, 2024 10:16:02 AM io.quarkus.config
2024-06-06 12:16:04 WARN: Unrecognized configuration key "quarkus.consul.registration.service-id" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2024-06-06 12:16:04 Jun 06, 2024 10:16:02 AM io.quarkus.config
2024-06-06 12:16:04 WARN: Unrecognized configuration key "quarkus.consul.registration.port" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2024-06-06 12:16:04 Jun 06, 2024 10:16:02 AM io.quarkus.config
2024-06-06 12:16:04 WARN: Unrecognized configuration key "quarkus.consul.registration.enabled" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2024-06-06 12:16:04 Jun 06, 2024 10:16:02 AM io.quarkus.config
2024-06-06 12:16:04 WARN: Unrecognized configuration key "quarkus.consul.registration.host" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2024-06-06 12:16:04 Jun 06, 2024 10:16:02 AM io.quarkus.config
2024-06-06 12:16:04 WARN: Unrecognized configuration key "quarkus.consul-config.default-config" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2024-06-06 12:16:04 Jun 06, 2024 10:16:02 AM io.quarkus.config
2024-06-06 12:16:04 WARN: Unrecognized configuration key "quarkus.consul.registration.service-name" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2024-06-06 12:16:05 Configuration validation failed:
2024-06-06 12:16:05 SRCFG00050: quarkus.consul-config.apps-config.enabled in io.smallrye.config.ConfigSourceContext$ConfigSourceContextConfigSource does not map to any root
2024-06-06 12:16:05 SRCFG00050: quarkus.consul-config.default-config in io.smallrye.config.ConfigSourceContext$ConfigSourceContextConfigSource does not map to any root
2024-06-06 12:16:05 java.lang.RuntimeException: Failed to start quarkus
2024-06-06 12:16:05 at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
2024-06-06 12:16:05 at io.quarkus.runtime.Application.start(Application.java:101)
2024-06-06 12:16:05 at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:111)
2024-06-06 12:16:05 at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
2024-06-06 12:16:05 at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
2024-06-06 12:16:05 at io.quarkus.runtime.Quarkus.run(Quarkus.java:124)
2024-06-06 12:16:05 at io.quarkus.runner.GeneratedMain.main(Unknown Source)
2024-06-06 12:16:05 at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
2024-06-06 12:16:05 at java.base/java.lang.reflect.Method.invoke(Unknown Source)
2024-06-06 12:16:05 at io.quarkus.bootstrap.runner.QuarkusEntryPoint.doRun(QuarkusEntryPoint.java:62)
2024-06-06 12:16:05 at io.quarkus.bootstrap.runner.QuarkusEntryPoint.main(QuarkusEntryPoint.java:33)
2024-06-06 12:16:05 Caused by: io.quarkus.runtime.configuration.ConfigurationException: Failed to read configuration properties
2024-06-06 12:16:05 at io.quarkus.deployment.steps.RuntimeConfigSetup.deploy(Unknown Source)
2024-06-06 12:16:05 ... 11 more
2024-06-06 12:16:05 Caused by: io.smallrye.config.ConfigValidationException: Configuration validation failed:
2024-06-06 12:16:05 SRCFG00050: quarkus.consul-config.apps-config.enabled in io.smallrye.config.ConfigSourceContext$ConfigSourceContextConfigSource does not map to any root
2024-06-06 12:16:05 SRCFG00050: quarkus.consul-config.default-config in io.smallrye.config.ConfigSourceContext$ConfigSourceContextConfigSource does not map to any root
2024-06-06 12:16:05 at io.smallrye.config.ConfigMappingProvider.mapConfiguration(ConfigMappingProvider.java:75)
2024-06-06 12:16:05 at io.smallrye.config.SmallRyeConfig.<init>(SmallRyeConfig.java:84)
2024-06-06 12:16:05 at io.smallrye.config.SmallRyeConfigBuilder.build(SmallRyeConfigBuilder.java:714)
2024-06-06 12:16:05 at io.smallrye.config.ConfigSourceFactory$ConfigurableConfigSourceFactory.getConfigSources(ConfigSourceFactory.java:55)
2024-06-06 12:16:05 at io.smallrye.config.ConfigurableConfigSource.getConfigSources(ConfigurableConfigSource.java:50)
2024-06-06 12:16:05 at io.smallrye.config.SmallRyeConfig$ConfigSources.mapLateSources(SmallRyeConfig.java:862)
2024-06-06 12:16:05 at io.smallrye.config.SmallRyeConfig$ConfigSources.<init>(SmallRyeConfig.java:737)
2024-06-06 12:16:05 at io.smallrye.config.SmallRyeConfig.<init>(SmallRyeConfig.java:81)
2024-06-06 12:16:05 at io.smallrye.config.SmallRyeConfigBuilder.build(SmallRyeConfigBuilder.java:714)
2024-06-06 12:16:05 at io.quarkus.runtime.generated.Config.readConfig(Unknown Source)
2024-06-06 12:16:05 at io.quarkus.runtime.generated.Config.createRunTimeConfig(Unknown Source)
2024-06-06 12:16:05 ... 12 more
<code>2024-06-06 12:16:04 Jun 06, 2024 10:16:02 AM io.quarkus.config
2024-06-06 12:16:04 WARN: Unrecognized configuration key "quarkus.consul-config.apps-config.enabled" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2024-06-06 12:16:04 Jun 06, 2024 10:16:02 AM io.quarkus.config
2024-06-06 12:16:04 WARN: Unrecognized configuration key "quarkus.consul.registration.service-id" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2024-06-06 12:16:04 Jun 06, 2024 10:16:02 AM io.quarkus.config
2024-06-06 12:16:04 WARN: Unrecognized configuration key "quarkus.consul.registration.port" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2024-06-06 12:16:04 Jun 06, 2024 10:16:02 AM io.quarkus.config
2024-06-06 12:16:04 WARN: Unrecognized configuration key "quarkus.consul.registration.enabled" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2024-06-06 12:16:04 Jun 06, 2024 10:16:02 AM io.quarkus.config
2024-06-06 12:16:04 WARN: Unrecognized configuration key "quarkus.consul.registration.host" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2024-06-06 12:16:04 Jun 06, 2024 10:16:02 AM io.quarkus.config
2024-06-06 12:16:04 WARN: Unrecognized configuration key "quarkus.consul-config.default-config" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2024-06-06 12:16:04 Jun 06, 2024 10:16:02 AM io.quarkus.config
2024-06-06 12:16:04 WARN: Unrecognized configuration key "quarkus.consul.registration.service-name" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2024-06-06 12:16:05 Configuration validation failed:
2024-06-06 12:16:05 SRCFG00050: quarkus.consul-config.apps-config.enabled in io.smallrye.config.ConfigSourceContext$ConfigSourceContextConfigSource does not map to any root
2024-06-06 12:16:05 SRCFG00050: quarkus.consul-config.default-config in io.smallrye.config.ConfigSourceContext$ConfigSourceContextConfigSource does not map to any root
2024-06-06 12:16:05 java.lang.RuntimeException: Failed to start quarkus
2024-06-06 12:16:05 at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
2024-06-06 12:16:05 at io.quarkus.runtime.Application.start(Application.java:101)
2024-06-06 12:16:05 at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:111)
2024-06-06 12:16:05 at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
2024-06-06 12:16:05 at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
2024-06-06 12:16:05 at io.quarkus.runtime.Quarkus.run(Quarkus.java:124)
2024-06-06 12:16:05 at io.quarkus.runner.GeneratedMain.main(Unknown Source)
2024-06-06 12:16:05 at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
2024-06-06 12:16:05 at java.base/java.lang.reflect.Method.invoke(Unknown Source)
2024-06-06 12:16:05 at io.quarkus.bootstrap.runner.QuarkusEntryPoint.doRun(QuarkusEntryPoint.java:62)
2024-06-06 12:16:05 at io.quarkus.bootstrap.runner.QuarkusEntryPoint.main(QuarkusEntryPoint.java:33)
2024-06-06 12:16:05 Caused by: io.quarkus.runtime.configuration.ConfigurationException: Failed to read configuration properties
2024-06-06 12:16:05 at io.quarkus.deployment.steps.RuntimeConfigSetup.deploy(Unknown Source)
2024-06-06 12:16:05 ... 11 more
2024-06-06 12:16:05 Caused by: io.smallrye.config.ConfigValidationException: Configuration validation failed:
2024-06-06 12:16:05 SRCFG00050: quarkus.consul-config.apps-config.enabled in io.smallrye.config.ConfigSourceContext$ConfigSourceContextConfigSource does not map to any root
2024-06-06 12:16:05 SRCFG00050: quarkus.consul-config.default-config in io.smallrye.config.ConfigSourceContext$ConfigSourceContextConfigSource does not map to any root
2024-06-06 12:16:05 at io.smallrye.config.ConfigMappingProvider.mapConfiguration(ConfigMappingProvider.java:75)
2024-06-06 12:16:05 at io.smallrye.config.SmallRyeConfig.<init>(SmallRyeConfig.java:84)
2024-06-06 12:16:05 at io.smallrye.config.SmallRyeConfigBuilder.build(SmallRyeConfigBuilder.java:714)
2024-06-06 12:16:05 at io.smallrye.config.ConfigSourceFactory$ConfigurableConfigSourceFactory.getConfigSources(ConfigSourceFactory.java:55)
2024-06-06 12:16:05 at io.smallrye.config.ConfigurableConfigSource.getConfigSources(ConfigurableConfigSource.java:50)
2024-06-06 12:16:05 at io.smallrye.config.SmallRyeConfig$ConfigSources.mapLateSources(SmallRyeConfig.java:862)
2024-06-06 12:16:05 at io.smallrye.config.SmallRyeConfig$ConfigSources.<init>(SmallRyeConfig.java:737)
2024-06-06 12:16:05 at io.smallrye.config.SmallRyeConfig.<init>(SmallRyeConfig.java:81)
2024-06-06 12:16:05 at io.smallrye.config.SmallRyeConfigBuilder.build(SmallRyeConfigBuilder.java:714)
2024-06-06 12:16:05 at io.quarkus.runtime.generated.Config.readConfig(Unknown Source)
2024-06-06 12:16:05 at io.quarkus.runtime.generated.Config.createRunTimeConfig(Unknown Source)
2024-06-06 12:16:05 ... 12 more
</code>
2024-06-06 12:16:04 Jun 06, 2024 10:16:02 AM io.quarkus.config
2024-06-06 12:16:04 WARN: Unrecognized configuration key "quarkus.consul-config.apps-config.enabled" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2024-06-06 12:16:04 Jun 06, 2024 10:16:02 AM io.quarkus.config
2024-06-06 12:16:04 WARN: Unrecognized configuration key "quarkus.consul.registration.service-id" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2024-06-06 12:16:04 Jun 06, 2024 10:16:02 AM io.quarkus.config
2024-06-06 12:16:04 WARN: Unrecognized configuration key "quarkus.consul.registration.port" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2024-06-06 12:16:04 Jun 06, 2024 10:16:02 AM io.quarkus.config
2024-06-06 12:16:04 WARN: Unrecognized configuration key "quarkus.consul.registration.enabled" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2024-06-06 12:16:04 Jun 06, 2024 10:16:02 AM io.quarkus.config
2024-06-06 12:16:04 WARN: Unrecognized configuration key "quarkus.consul.registration.host" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2024-06-06 12:16:04 Jun 06, 2024 10:16:02 AM io.quarkus.config
2024-06-06 12:16:04 WARN: Unrecognized configuration key "quarkus.consul-config.default-config" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2024-06-06 12:16:04 Jun 06, 2024 10:16:02 AM io.quarkus.config
2024-06-06 12:16:04 WARN: Unrecognized configuration key "quarkus.consul.registration.service-name" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2024-06-06 12:16:05 Configuration validation failed:
2024-06-06 12:16:05 SRCFG00050: quarkus.consul-config.apps-config.enabled in io.smallrye.config.ConfigSourceContext$ConfigSourceContextConfigSource does not map to any root
2024-06-06 12:16:05 SRCFG00050: quarkus.consul-config.default-config in io.smallrye.config.ConfigSourceContext$ConfigSourceContextConfigSource does not map to any root
2024-06-06 12:16:05 java.lang.RuntimeException: Failed to start quarkus
2024-06-06 12:16:05 at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
2024-06-06 12:16:05 at io.quarkus.runtime.Application.start(Application.java:101)
2024-06-06 12:16:05 at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:111)
2024-06-06 12:16:05 at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
2024-06-06 12:16:05 at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
2024-06-06 12:16:05 at io.quarkus.runtime.Quarkus.run(Quarkus.java:124)
2024-06-06 12:16:05 at io.quarkus.runner.GeneratedMain.main(Unknown Source)
2024-06-06 12:16:05 at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
2024-06-06 12:16:05 at java.base/java.lang.reflect.Method.invoke(Unknown Source)
2024-06-06 12:16:05 at io.quarkus.bootstrap.runner.QuarkusEntryPoint.doRun(QuarkusEntryPoint.java:62)
2024-06-06 12:16:05 at io.quarkus.bootstrap.runner.QuarkusEntryPoint.main(QuarkusEntryPoint.java:33)
2024-06-06 12:16:05 Caused by: io.quarkus.runtime.configuration.ConfigurationException: Failed to read configuration properties
2024-06-06 12:16:05 at io.quarkus.deployment.steps.RuntimeConfigSetup.deploy(Unknown Source)
2024-06-06 12:16:05 ... 11 more
2024-06-06 12:16:05 Caused by: io.smallrye.config.ConfigValidationException: Configuration validation failed:
2024-06-06 12:16:05 SRCFG00050: quarkus.consul-config.apps-config.enabled in io.smallrye.config.ConfigSourceContext$ConfigSourceContextConfigSource does not map to any root
2024-06-06 12:16:05 SRCFG00050: quarkus.consul-config.default-config in io.smallrye.config.ConfigSourceContext$ConfigSourceContextConfigSource does not map to any root
2024-06-06 12:16:05 at io.smallrye.config.ConfigMappingProvider.mapConfiguration(ConfigMappingProvider.java:75)
2024-06-06 12:16:05 at io.smallrye.config.SmallRyeConfig.<init>(SmallRyeConfig.java:84)
2024-06-06 12:16:05 at io.smallrye.config.SmallRyeConfigBuilder.build(SmallRyeConfigBuilder.java:714)
2024-06-06 12:16:05 at io.smallrye.config.ConfigSourceFactory$ConfigurableConfigSourceFactory.getConfigSources(ConfigSourceFactory.java:55)
2024-06-06 12:16:05 at io.smallrye.config.ConfigurableConfigSource.getConfigSources(ConfigurableConfigSource.java:50)
2024-06-06 12:16:05 at io.smallrye.config.SmallRyeConfig$ConfigSources.mapLateSources(SmallRyeConfig.java:862)
2024-06-06 12:16:05 at io.smallrye.config.SmallRyeConfig$ConfigSources.<init>(SmallRyeConfig.java:737)
2024-06-06 12:16:05 at io.smallrye.config.SmallRyeConfig.<init>(SmallRyeConfig.java:81)
2024-06-06 12:16:05 at io.smallrye.config.SmallRyeConfigBuilder.build(SmallRyeConfigBuilder.java:714)
2024-06-06 12:16:05 at io.quarkus.runtime.generated.Config.readConfig(Unknown Source)
2024-06-06 12:16:05 at io.quarkus.runtime.generated.Config.createRunTimeConfig(Unknown Source)
2024-06-06 12:16:05 ... 12 more
It is important to say, that I do not have defined these properties in my application.properties
file. I also do not use @ConfigMap
in my code.
JFYI, the application.properties file looks like this:
<code>quarkus.http.port=8094
quarkus.http.host=0.0.0.0
kafka.auto.offset.reset=none
quarkus.log.category."org.apache.kafka".level=WARN
kafka.bootstrap.servers=localhost:29092,localhost:39092
mp.messaging.outgoing.orders-out.connector=smallrye-kafka
mp.messaging.outgoing.orders-out.topic=orders
quarkus.datasource.db-kind=postgresql
quarkus.datasource.username=fh
quarkus.datasource.password=fh
quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:6543/orders-db
quarkus.datasource.jdbc.max-size=10
quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.log.format-sql=false
#quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.smallrye-health.root-path=/actuator/health
quarkus.smallrye-health.enable-liveness=true
quarkus.smallrye-health.enable-readiness=true
<code>quarkus.http.port=8094
quarkus.http.host=0.0.0.0
kafka.auto.offset.reset=none
quarkus.log.category."org.apache.kafka".level=WARN
service.host=172.29.32.1
# Producer settings
kafka.bootstrap.servers=localhost:29092,localhost:39092
mp.messaging.outgoing.orders-out.connector=smallrye-kafka
mp.messaging.outgoing.orders-out.topic=orders
# Consul
consul.host=localhost
consul.port=8500
# Database
quarkus.datasource.db-kind=postgresql
quarkus.datasource.username=fh
quarkus.datasource.password=fh
quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:6543/orders-db
quarkus.datasource.jdbc.max-size=10
quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.log.format-sql=false
#quarkus.hibernate-orm.database.generation=drop-and-create
# Health
quarkus.http.root-path=/
quarkus.smallrye-health.root-path=/actuator/health
quarkus.smallrye-health.enable-liveness=true
quarkus.smallrye-health.enable-readiness=true
</code>
quarkus.http.port=8094
quarkus.http.host=0.0.0.0
kafka.auto.offset.reset=none
quarkus.log.category."org.apache.kafka".level=WARN
service.host=172.29.32.1
# Producer settings
kafka.bootstrap.servers=localhost:29092,localhost:39092
mp.messaging.outgoing.orders-out.connector=smallrye-kafka
mp.messaging.outgoing.orders-out.topic=orders
# Consul
consul.host=localhost
consul.port=8500
# Database
quarkus.datasource.db-kind=postgresql
quarkus.datasource.username=fh
quarkus.datasource.password=fh
quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:6543/orders-db
quarkus.datasource.jdbc.max-size=10
quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.log.format-sql=false
#quarkus.hibernate-orm.database.generation=drop-and-create
# Health
quarkus.http.root-path=/
quarkus.smallrye-health.root-path=/actuator/health
quarkus.smallrye-health.enable-liveness=true
quarkus.smallrye-health.enable-readiness=true
When starting the application locally, I use eclipse-temurin:21-jre and I also use the same as my base image in the Dockerfile.
My Dockerfile looks like this:
<code>FROM eclipse-temurin:21-jre
# We make four distinct layers so if there are application changes the library layers can be re-used
COPY --chown=185 build/quarkus-app/lib/ /deployments/lib/
COPY --chown=185 build/quarkus-app/*.jar /deployments/
COPY --chown=185 build/quarkus-app/app/ /deployments/app/
COPY --chown=185 build/quarkus-app/quarkus/ /deployments/quarkus/
ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0"
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
ENTRYPOINT ["java", "-jar", "/deployments/quarkus-run.jar"]
<code>FROM eclipse-temurin:21-jre
ENV LANGUAGE='en_US:en'
# We make four distinct layers so if there are application changes the library layers can be re-used
COPY --chown=185 build/quarkus-app/lib/ /deployments/lib/
COPY --chown=185 build/quarkus-app/*.jar /deployments/
COPY --chown=185 build/quarkus-app/app/ /deployments/app/
COPY --chown=185 build/quarkus-app/quarkus/ /deployments/quarkus/
EXPOSE 8098
USER 185
ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0"
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
ENTRYPOINT ["java", "-jar", "/deployments/quarkus-run.jar"]
</code>
FROM eclipse-temurin:21-jre
ENV LANGUAGE='en_US:en'
# We make four distinct layers so if there are application changes the library layers can be re-used
COPY --chown=185 build/quarkus-app/lib/ /deployments/lib/
COPY --chown=185 build/quarkus-app/*.jar /deployments/
COPY --chown=185 build/quarkus-app/app/ /deployments/app/
COPY --chown=185 build/quarkus-app/quarkus/ /deployments/quarkus/
EXPOSE 8098
USER 185
ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0"
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
ENTRYPOINT ["java", "-jar", "/deployments/quarkus-run.jar"]
I already tried several things to solve the issue, but none of them worked:
- adding the gradle dependency
io.quarkiverse.config:quarkus-config-consul
- disabling the config property validation in application.properties
Additional information:
The code for registering the service in Consul:
public class ServiceRegistration {
@ConfigProperty(name = "consul.host") String host;
@ConfigProperty(name = "consul.port") int port;
@ConfigProperty(name = "quarkus.http.port", defaultValue = "8094") int servicePort;
@ConfigProperty(name = "service.host", defaultValue = "localhost") String serviceHost;
* Register our two services in Consul.
* Note: this method is called on a worker thread, and so it is allowed to block.
public void init(@Observes StartupEvent ev, Vertx vertx) {
ConsulClient client = ConsulClient.create(vertx,
new ConsulClientOptions()
ServiceOptions serviceOptions = new ServiceOptions()
.setName("ordering-system");
CheckOptions checkOptions = new CheckOptions()
.setHttp("http://" + serviceHost + ":" + servicePort + "/actuator/health")
.setDeregisterAfter("1m");
serviceOptions.setCheckOptions(checkOptions);
client.registerServiceAndAwait(serviceOptions);
<code>@ApplicationScoped
public class ServiceRegistration {
@ConfigProperty(name = "consul.host") String host;
@ConfigProperty(name = "consul.port") int port;
@ConfigProperty(name = "quarkus.http.port", defaultValue = "8094") int servicePort;
@ConfigProperty(name = "service.host", defaultValue = "localhost") String serviceHost;
/**
* Register our two services in Consul.
*
* Note: this method is called on a worker thread, and so it is allowed to block.
*/
public void init(@Observes StartupEvent ev, Vertx vertx) {
ConsulClient client = ConsulClient.create(vertx,
new ConsulClientOptions()
.setHost(host)
.setPort(port));
ServiceOptions serviceOptions = new ServiceOptions()
.setPort(servicePort)
.setAddress(serviceHost)
.setName("ordering-system");
CheckOptions checkOptions = new CheckOptions()
.setHttp("http://" + serviceHost + ":" + servicePort + "/actuator/health")
.setInterval("10s")
.setDeregisterAfter("1m");
serviceOptions.setCheckOptions(checkOptions);
client.registerServiceAndAwait(serviceOptions);
}
}
</code>
@ApplicationScoped
public class ServiceRegistration {
@ConfigProperty(name = "consul.host") String host;
@ConfigProperty(name = "consul.port") int port;
@ConfigProperty(name = "quarkus.http.port", defaultValue = "8094") int servicePort;
@ConfigProperty(name = "service.host", defaultValue = "localhost") String serviceHost;
/**
* Register our two services in Consul.
*
* Note: this method is called on a worker thread, and so it is allowed to block.
*/
public void init(@Observes StartupEvent ev, Vertx vertx) {
ConsulClient client = ConsulClient.create(vertx,
new ConsulClientOptions()
.setHost(host)
.setPort(port));
ServiceOptions serviceOptions = new ServiceOptions()
.setPort(servicePort)
.setAddress(serviceHost)
.setName("ordering-system");
CheckOptions checkOptions = new CheckOptions()
.setHttp("http://" + serviceHost + ":" + servicePort + "/actuator/health")
.setInterval("10s")
.setDeregisterAfter("1m");
serviceOptions.setCheckOptions(checkOptions);
client.registerServiceAndAwait(serviceOptions);
}
}