Skip to content

Commit

Permalink
WIP Add extension for Apicurio Registry Avro
Browse files Browse the repository at this point in the history
  • Loading branch information
Ladicek committed Jun 7, 2021
1 parent c8cd44a commit 3b76306
Show file tree
Hide file tree
Showing 15 changed files with 492 additions and 55 deletions.
16 changes: 16 additions & 0 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@
<log4j2-jboss-logmanager.version>1.0.0.Final</log4j2-jboss-logmanager.version>
<log4j-jboss-logmanager.version>1.2.0.Final</log4j-jboss-logmanager.version>
<avro.version>1.10.2</avro.version>
<apicurio-registry.version>2.0.0.Final</apicurio-registry.version>
<jacoco.version>0.8.7</jacoco.version>
<testcontainers.version>1.15.3</testcontainers.version>
<docker-java.version>3.2.8</docker-java.version> <!-- must be the version Testcontainers use -->
Expand Down Expand Up @@ -1106,6 +1107,16 @@
<artifactId>quarkus-avro-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-apicurio-registry-avro</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-apicurio-registry-avro-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-health</artifactId>
Expand Down Expand Up @@ -2824,6 +2835,11 @@
<artifactId>agroal-pool</artifactId>
<version>${agroal.version}</version>
</dependency>
<dependency>
<groupId>io.apicurio</groupId>
<artifactId>apicurio-registry-serdes-avro-serde</artifactId>
<version>${apicurio-registry.version}</version>
</dependency>
<dependency>
<groupId>io.smallrye.reactive</groupId>
<artifactId>mutiny</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public enum Feature {
AMAZON_SES,
AMAZON_KMS,
AMAZON_SSM,
APICURIO_REGISTRY_AVRO,
ARTEMIS_CORE,
ARTEMIS_JMS,
CACHE,
Expand Down
13 changes: 13 additions & 0 deletions devtools/bom-descriptor-json/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-apicurio-registry-avro</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-apicurio-registry-avro-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc-deployment</artifactId>
Expand Down
19 changes: 1 addition & 18 deletions docs/src/main/asciidoc/kafka-schema-registry-avro.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,10 @@ mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \
-DprojectArtifactId=kafka-avro-schema-quickstart \
-DclassName="org.acme.kafka.MovieResource" \
-Dpath="/movies" \
-Dextensions="resteasy-reactive,resteasy-reactive-jackson,smallrye-reactive-messaging-kafka,avro"
-Dextensions="resteasy-reactive,resteasy-reactive-jackson,smallrye-reactive-messaging-kafka,apicurio-registry-avro"
cd kafka-avro-schema-quickstart
----

Additionally, we need a serializer and deserializer for Avro.
In this guide, we will use the ones provided by Apicurio.

[source,xml]
----
<dependency>
<groupId>io.apicurio</groupId>
<artifactId>apicurio-registry-serdes-avro-serde</artifactId>
<version>2.0.0.Final</version>
</dependency>
<!-- Apicurio Registry libraries use Keycloak client, which requires Apache HTTP Client -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-apache-httpclient</artifactId>
</dependency>
----

[TIP]
====
If you use Confluent Schema Registry, you need the following dependencies and the Confluent Maven repository added
Expand Down
56 changes: 56 additions & 0 deletions extensions/apicurio-registry-avro/deployment/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-apicurio-registry-avro-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>

<artifactId>quarkus-apicurio-registry-avro-deployment</artifactId>
<name>Quarkus - Apicurio Registry - Avro - Deployment</name>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-apicurio-registry-avro</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core-deployment</artifactId>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package io.quarkus.apicurio.registry.avro;

import io.quarkus.deployment.Feature;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;

public class ApicurioRegistryAvroProcessor {
@BuildStep
FeatureBuildItem feature() {
return new FeatureBuildItem(Feature.APICURIO_REGISTRY_AVRO);
}

@BuildStep
public void apicurioRegistryAvro(BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
BuildProducer<ExtensionSslNativeSupportBuildItem> sslNativeSupport) {

reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, false,
"io.apicurio.registry.serde.avro.AvroKafkaDeserializer",
"io.apicurio.registry.serde.avro.AvroKafkaSerializer"));

reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, false,
"io.apicurio.registry.serde.strategy.SimpleTopicIdStrategy",
"io.apicurio.registry.serde.strategy.TopicIdStrategy",
"io.apicurio.registry.serde.avro.DefaultAvroDatumProvider",
"io.apicurio.registry.serde.avro.ReflectAvroDatumProvider",
"io.apicurio.registry.serde.avro.strategy.RecordIdStrategy",
"io.apicurio.registry.serde.avro.strategy.TopicRecordIdStrategy"));

reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, false,
"io.apicurio.registry.serde.DefaultSchemaResolver",
"io.apicurio.registry.serde.DefaultIdHandler",
"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));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.quarkus.apicurio.registry.avro;

import java.util.Optional;

import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;

@ConfigRoot(name = "apicurio-registry.devservices", phase = ConfigPhase.BUILD_TIME)
public class ApicurioRegistryDevServicesBuildTimeConfig {

/**
* If Dev Services for Apicurio Registry has been explicitly enabled or disabled. Dev Services are generally enabled
* by default, unless there is an existing configuration present.
*/
@ConfigItem
public Optional<Boolean> enabled = Optional.empty();

/**
* Optional fixed port the dev service will listen to.
* <p>
* If not defined, the port will be chosen randomly.
*/
@ConfigItem
public Optional<Integer> port;

/**
* The Apicurio Registry image to use.
* Note that only Apicurio Registry 2.x images are supported.
*/
@ConfigItem(defaultValue = "apicurio/apicurio-registry-mem:2.0.0.Final")
public String imageName;

}
Loading

0 comments on commit 3b76306

Please sign in to comment.