quarkusio / quarkus

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

Apicurio Registry DevService cannot be used by multiple Quarkus services #24008

Closed sombraglez closed 2 years ago

sombraglez commented 2 years ago

Describe the bug

Currently I'm trying to connect two simple Quarkus services using the default DevServices as Kafka broker and schema registry. According to the logs both services can successfully find the DevServices, which are automatically started by Quarkus. However, by trying to send a first message into the configured topic the following error occurs:

ERROR [io.sma.rea.mes.kafka] (smallrye-kafka-producer-thread-0) SRMSG18260: Unable to recover from the serialization failure (topic: movies), configure a SerializationFailureHandler to recover from errors.: io.vertx.core.VertxException: Invalid url: localhost:64263/apis/registry/v2/groups/default/artifacts?ifExists=RETURN_OR_UPDATE&canonical=false
        at io.vertx.core.http.RequestOptions.parseUrl(RequestOptions.java:357)
        at io.vertx.core.http.RequestOptions.setAbsoluteURI(RequestOptions.java:370)
        at io.apicurio.rest.client.VertxHttpClient.sendRequest(VertxHttpClient.java:74)
        at io.apicurio.registry.rest.client.impl.RegistryClientImpl.createArtifact(RegistryClientImpl.java:236)
        at io.apicurio.registry.rest.client.RegistryClient.createArtifact(RegistryClient.java:139)
        at io.apicurio.registry.serde.DefaultSchemaResolver.lambda$handleAutoCreateArtifact$2(DefaultSchemaResolver.java:174)
        at io.apicurio.registry.serde.ERCache.lambda$getValue$0(ERCache.java:132)
        at io.apicurio.registry.serde.ERCache.retry(ERCache.java:171)
        at io.apicurio.registry.serde.ERCache.getValue(ERCache.java:131)
        at io.apicurio.registry.serde.ERCache.getByContent(ERCache.java:116)
        at io.apicurio.registry.serde.DefaultSchemaResolver.handleAutoCreateArtifact(DefaultSchemaResolver.java:172)
        at io.apicurio.registry.serde.DefaultSchemaResolver.resolveSchema(DefaultSchemaResolver.java:82)
        at io.apicurio.registry.serde.AbstractKafkaSerializer.serialize(AbstractKafkaSerializer.java:92)
        at io.smallrye.reactive.messaging.kafka.fault.SerializerWrapper.lambda$serialize$1(SerializerWrapper.java:56)
        at io.smallrye.reactive.messaging.kafka.fault.SerializerWrapper.wrapSerialize(SerializerWrapper.java:81)
        at io.smallrye.reactive.messaging.kafka.fault.SerializerWrapper.serialize(SerializerWrapper.java:56)
        at org.apache.kafka.clients.producer.KafkaProducer.doSend(KafkaProducer.java:945)
        at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:905)
        at io.smallrye.reactive.messaging.kafka.impl.ReactiveKafkaProducer.lambda$send$3(ReactiveKafkaProducer.java:111)
        at io.smallrye.context.impl.wrappers.SlowContextualConsumer.accept(SlowContextualConsumer.java:21)
        at io.smallrye.mutiny.operators.uni.builders.UniCreateWithEmitter.subscribe(UniCreateWithEmitter.java:22)
        at io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:36)
        at io.smallrye.mutiny.operators.uni.UniRunSubscribeOn.lambda$subscribe$0(UniRunSubscribeOn.java:27)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.net.MalformedURLException: unknown protocol: localhost
        at java.base/java.net.URL.<init>(URL.java:652)
        at java.base/java.net.URL.<init>(URL.java:541)
        at java.base/java.net.URL.<init>(URL.java:488)
        at io.vertx.core.http.RequestOptions.parseUrl(RequestOptions.java:355)
        ... 25 more

This error only occurs on the Quarkus service (consumer or producer), which connects to an already existing Apicurio Registry started as Devservice.

Expected behavior

Multiple Quarkus Services in Dev mode can connect to an existing Apicurio Registry DevService automatically started by one of them

Actual behavior

The configured URL to an Apicurio Registry DevService contains no protocol for those services, which try to connect an existing instance of the DevService

How to Reproduce?

Using following consumer and producer services:

https://github.com/sombraglez/quarkus-kafka-avro-schema-consumer https://github.com/sombraglez/quarkus-kafka-avro-schema-producer

  1. Start consumer quarkus-kafka-avro-schema-consumer in Dev mode mvn quarkus:dev
  2. Start producer quarkus-kafka-avro-schema-producer in Dev mode mvn quarkus:dev
  3. Access consumer REST-EndPoint http://localhost:8081/consumed-movies
  4. Produce a message via POST at http://localhost:8080/movies

Output of uname -a or ver

No response

Output of java -version

openjdk 11.0.14 2022-01-18 LTS

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.7.2.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.2

Additional information

No response

edeandrea commented 2 years ago

+1 to this as well as this affects the superheroes sample app (https://github.com/quarkusio/quarkus-super-heroes). That app is using Quarkus version 2.7.3.Final.

edeandrea commented 2 years ago

/cc @cescoffier @carlesarnal

cescoffier commented 2 years ago

@edeandrea @sombraglez - See https://github.com/quarkusio/quarkus/pull/24142.

@sombraglez thank you for the reproducer!

quarkus-bot[bot] commented 2 years ago

/cc @cescoffier, @ozangunalp