From a23c7b9f1bec589f88b90bee22e36ecfee5731f9 Mon Sep 17 00:00:00 2001 From: Carles Arnal Date: Fri, 1 Oct 2021 11:21:29 +0200 Subject: [PATCH] Update to Apicurio Registry 2.1.1.Final and use Vert.x HTTP client --- bom/application/pom.xml | 8 +++++++- .../main/asciidoc/kafka-schema-registry-avro.adoc | 4 ++-- .../apicurio-registry-avro/deployment/pom.xml | 2 +- .../avro/ApicurioRegistryAvroProcessor.java | 12 ++++++++---- ...ApicurioRegistryDevServicesBuildTimeConfig.java | 2 +- extensions/apicurio-registry-avro/runtime/pom.xml | 13 +++++++++++-- .../registry/avro/ApicurioRegistryClient.java | 14 ++++++++++++++ integration-tests/kafka-avro-apicurio2/pom.xml | 2 +- .../kafka/KafkaAndSchemaRegistryTestResource.java | 2 +- .../test/java/io/quarkus/it/kafka/KafkaAvroIT.java | 10 ++++++++++ 10 files changed, 56 insertions(+), 13 deletions(-) create mode 100644 extensions/apicurio-registry-avro/runtime/src/main/java/io/quarkus/apicurio/registry/avro/ApicurioRegistryClient.java diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 7c55e28cacd1d..7696cc7dc1d07 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -201,7 +201,8 @@ 1.0.0.Final 1.2.2.Final 1.11.0 - 2.0.1.Final + 2.1.1.Final + 0.0.9.Final 0.8.7 1.16.2 3.2.12 @@ -3046,6 +3047,11 @@ apicurio-registry-serdes-avro-serde ${apicurio-registry.version} + + io.apicurio + apicurio-common-rest-client-vertx + ${apicurio-common-rest-client.version} + io.quarkus diff --git a/docs/src/main/asciidoc/kafka-schema-registry-avro.adoc b/docs/src/main/asciidoc/kafka-schema-registry-avro.adoc index e31ad1b5aa98e..9e2a96eebdf59 100644 --- a/docs/src/main/asciidoc/kafka-schema-registry-avro.adoc +++ b/docs/src/main/asciidoc/kafka-schema-registry-avro.adoc @@ -392,7 +392,7 @@ services: KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 schema-registry: - image: apicurio/apicurio-registry-mem:2.0.1.Final + image: apicurio/apicurio-registry-mem:2.1.1.Final ports: - 8081:8080 depends_on: @@ -607,7 +607,7 @@ public class KafkaAndSchemaRegistryTestResource implements QuarkusTestResourceLi @Override public Map start() { kafka.start(); - registry = new GenericContainer<>("apicurio/apicurio-registry-mem:2.0.1.Final") + registry = new GenericContainer<>("apicurio/apicurio-registry-mem:2.1.1.Final") .withExposedPorts(8080) .withEnv("QUARKUS_PROFILE", "prod"); registry.start(); diff --git a/extensions/apicurio-registry-avro/deployment/pom.xml b/extensions/apicurio-registry-avro/deployment/pom.xml index d6d94877f4efe..e8bcbb53b9bc1 100644 --- a/extensions/apicurio-registry-avro/deployment/pom.xml +++ b/extensions/apicurio-registry-avro/deployment/pom.xml @@ -29,7 +29,7 @@ io.quarkus - quarkus-apache-httpclient-deployment + quarkus-vertx-deployment diff --git a/extensions/apicurio-registry-avro/deployment/src/main/java/io/quarkus/apicurio/registry/avro/ApicurioRegistryAvroProcessor.java b/extensions/apicurio-registry-avro/deployment/src/main/java/io/quarkus/apicurio/registry/avro/ApicurioRegistryAvroProcessor.java index cca84983b1891..bf9d58d364142 100644 --- a/extensions/apicurio-registry-avro/deployment/src/main/java/io/quarkus/apicurio/registry/avro/ApicurioRegistryAvroProcessor.java +++ b/extensions/apicurio-registry-avro/deployment/src/main/java/io/quarkus/apicurio/registry/avro/ApicurioRegistryAvroProcessor.java @@ -3,9 +3,12 @@ import io.quarkus.deployment.Feature; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.annotations.ExecutionTime; +import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; import io.quarkus.deployment.builditem.FeatureBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; +import io.quarkus.vertx.deployment.VertxBuildItem; public class ApicurioRegistryAvroProcessor { @BuildStep @@ -35,10 +38,11 @@ public void apicurioRegistryAvro(BuildProducer reflect "io.apicurio.registry.serde.Legacy4ByteIdHandler", "io.apicurio.registry.serde.fallback.DefaultFallbackArtifactProvider", "io.apicurio.registry.serde.headers.DefaultHeadersHandler")); + } - // Apicurio Registry 2.x uses the JDK 11 HTTP client, which unconditionally requires SSL - // TODO when the new HTTP client SPI in Apicurio Registry client appears, this will no longer be needed - // (but we'll have to make sure that the Vert.x HTTP client is used) - sslNativeSupport.produce(new ExtensionSslNativeSupportBuildItem(Feature.APICURIO_REGISTRY_AVRO)); + @BuildStep + @Record(ExecutionTime.RUNTIME_INIT) + public void apicurioRegistryClient(VertxBuildItem vertx, ApicurioRegistryClient client) { + client.setup(vertx.getVertx()); } } diff --git a/extensions/apicurio-registry-avro/deployment/src/main/java/io/quarkus/apicurio/registry/avro/ApicurioRegistryDevServicesBuildTimeConfig.java b/extensions/apicurio-registry-avro/deployment/src/main/java/io/quarkus/apicurio/registry/avro/ApicurioRegistryDevServicesBuildTimeConfig.java index 051d7423592eb..7784d8be3df01 100644 --- a/extensions/apicurio-registry-avro/deployment/src/main/java/io/quarkus/apicurio/registry/avro/ApicurioRegistryDevServicesBuildTimeConfig.java +++ b/extensions/apicurio-registry-avro/deployment/src/main/java/io/quarkus/apicurio/registry/avro/ApicurioRegistryDevServicesBuildTimeConfig.java @@ -29,7 +29,7 @@ public class ApicurioRegistryDevServicesBuildTimeConfig { * The Apicurio Registry image to use. * Note that only Apicurio Registry 2.x images are supported. */ - @ConfigItem(defaultValue = "apicurio/apicurio-registry-mem:2.0.1.Final") + @ConfigItem(defaultValue = "apicurio/apicurio-registry-mem:2.1.1.Final") public String imageName; /** diff --git a/extensions/apicurio-registry-avro/runtime/pom.xml b/extensions/apicurio-registry-avro/runtime/pom.xml index 39cafeefaf44d..a0ad9a498a8fe 100644 --- a/extensions/apicurio-registry-avro/runtime/pom.xml +++ b/extensions/apicurio-registry-avro/runtime/pom.xml @@ -17,6 +17,16 @@ io.apicurio apicurio-registry-serdes-avro-serde + + + io.apicurio + apicurio-common-rest-client-jdk + + + + + io.apicurio + apicurio-common-rest-client-vertx @@ -27,10 +37,9 @@ io.quarkus quarkus-avro - io.quarkus - quarkus-apache-httpclient + quarkus-vertx diff --git a/extensions/apicurio-registry-avro/runtime/src/main/java/io/quarkus/apicurio/registry/avro/ApicurioRegistryClient.java b/extensions/apicurio-registry-avro/runtime/src/main/java/io/quarkus/apicurio/registry/avro/ApicurioRegistryClient.java new file mode 100644 index 0000000000000..ceae6a11f3a5c --- /dev/null +++ b/extensions/apicurio-registry-avro/runtime/src/main/java/io/quarkus/apicurio/registry/avro/ApicurioRegistryClient.java @@ -0,0 +1,14 @@ +package io.quarkus.apicurio.registry.avro; + +import io.apicurio.registry.rest.client.RegistryClientFactory; +import io.apicurio.rest.client.VertxHttpClientProvider; +import io.quarkus.runtime.RuntimeValue; +import io.quarkus.runtime.annotations.Recorder; +import io.vertx.core.Vertx; + +@Recorder +public class ApicurioRegistryClient { + public void setup(RuntimeValue vertx) { + RegistryClientFactory.setProvider(new VertxHttpClientProvider(vertx.getValue())); + } +} diff --git a/integration-tests/kafka-avro-apicurio2/pom.xml b/integration-tests/kafka-avro-apicurio2/pom.xml index c0acba3e57aba..00e9d565b4f55 100644 --- a/integration-tests/kafka-avro-apicurio2/pom.xml +++ b/integration-tests/kafka-avro-apicurio2/pom.xml @@ -22,7 +22,7 @@ --> - 2.0.1.Final + 2.1.1.Final diff --git a/integration-tests/kafka-avro-apicurio2/src/test/java/io/quarkus/it/kafka/KafkaAndSchemaRegistryTestResource.java b/integration-tests/kafka-avro-apicurio2/src/test/java/io/quarkus/it/kafka/KafkaAndSchemaRegistryTestResource.java index 3f6cdf3f524d6..7ce96655b1826 100644 --- a/integration-tests/kafka-avro-apicurio2/src/test/java/io/quarkus/it/kafka/KafkaAndSchemaRegistryTestResource.java +++ b/integration-tests/kafka-avro-apicurio2/src/test/java/io/quarkus/it/kafka/KafkaAndSchemaRegistryTestResource.java @@ -29,7 +29,7 @@ public static String getApicurioSchemaRegistryUrl() { @Override public Map start() { kafka.start(); - registry = new GenericContainer<>("apicurio/apicurio-registry-mem:2.0.1.Final") + registry = new GenericContainer<>("apicurio/apicurio-registry-mem:2.1.1.Final") .withExposedPorts(8080) .withEnv("QUARKUS_PROFILE", "prod"); registry.start(); diff --git a/integration-tests/kafka-avro-apicurio2/src/test/java/io/quarkus/it/kafka/KafkaAvroIT.java b/integration-tests/kafka-avro-apicurio2/src/test/java/io/quarkus/it/kafka/KafkaAvroIT.java index 4a2f287947a0c..5030447a2e022 100644 --- a/integration-tests/kafka-avro-apicurio2/src/test/java/io/quarkus/it/kafka/KafkaAvroIT.java +++ b/integration-tests/kafka-avro-apicurio2/src/test/java/io/quarkus/it/kafka/KafkaAvroIT.java @@ -1,10 +1,20 @@ package io.quarkus.it.kafka; +import org.junit.jupiter.api.BeforeAll; + +import io.apicurio.registry.rest.client.RegistryClientFactory; +import io.apicurio.rest.client.VertxHttpClientProvider; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; +import io.vertx.core.Vertx; @QuarkusIntegrationTest @QuarkusTestResource(KafkaAndSchemaRegistryTestResource.class) public class KafkaAvroIT extends KafkaAvroTest { + @BeforeAll + public static void setUp() { + // this is for the test JVM, which also uses Kafka client, which in turn also interacts with the registry + RegistryClientFactory.setProvider(new VertxHttpClientProvider(Vertx.vertx())); + } }