Skip to content

Commit

Permalink
Add Kafka extension
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Feb 21, 2019
1 parent 02937d6 commit e24115b
Show file tree
Hide file tree
Showing 23 changed files with 659 additions and 72 deletions.
13 changes: 13 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-kafka-client-deployment</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-smallrye-health-deployment</artifactId>
Expand Down Expand Up @@ -101,6 +108,12 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-smallrye-reactive-messaging-kafka-deployment</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.jboss.shamrock</groupId>
Expand Down
69 changes: 69 additions & 0 deletions build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@
<test-containers.version>1.10.6</test-containers.version>
<jboss-logging.version>3.3.2.Final</jboss-logging.version>
<vertx-axle-client.version>0.0.1</vertx-axle-client.version>
<kafka-clients.version>1.1.0</kafka-clients.version>
<kafka2.version>1.1.0</kafka2.version>
<debezium.version>0.8.3.Final</debezium.version>
<zookeeper.version>3.4.10</zookeeper.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -229,6 +233,16 @@
<artifactId>shamrock-jdbc-mariadb-runtime</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-kafka-client-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-kafka-client-runtime</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-smallrye-health-deployment</artifactId>
Expand Down Expand Up @@ -513,6 +527,16 @@
<artifactId>shamrock-smallrye-reactive-messaging-runtime</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-smallrye-reactive-messaging-kafka-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-smallrye-reactive-messaging-kafka-runtime</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-spring-di-deployment</artifactId>
Expand Down Expand Up @@ -618,6 +642,11 @@
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>jakarta.activation</artifactId>
Expand Down Expand Up @@ -707,6 +736,30 @@
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>io.debezium</groupId>
<artifactId>debezium-core</artifactId>
<version>${debezium.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.debezium</groupId>
<artifactId>debezium-core</artifactId>
<version>${debezium.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-reflect</artifactId>
<version>2.12.2</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.12.2</version>
</dependency>
<dependency>
<groupId>io.undertow</groupId>
<artifactId>undertow-servlet</artifactId>
Expand Down Expand Up @@ -858,6 +911,22 @@
<artifactId>httpcore</artifactId>
<version>${httpcore.version}</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>${kafka-clients.version}</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.12</artifactId>
<version>${kafka2.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${zookeeper.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

<parent>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-reactive-messaging</artifactId>
<artifactId>shamrock-kafka-client</artifactId>
<version>1.0.0.Alpha1-SNAPSHOT</version>
</parent>

<artifactId>shamrock-reactive-messaging-kafka-connector-deployment</artifactId>
<artifactId>shamrock-kafka-client-deployment</artifactId>

<dependencies>
<dependency>
Expand All @@ -19,15 +19,8 @@
</dependency>
<dependency>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-arc-deployment</artifactId>
<artifactId>shamrock-kafka-client-runtime</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-reactive-messaging-kafka-connector-runtime</artifactId>
<!-- TODO Write in BOM -->
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-junit5-internal</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package org.jboss.shamrock.reactivemessaging;

import org.apache.kafka.clients.consumer.RangeAssignor;
import org.apache.kafka.clients.producer.internals.DefaultPartitioner;
import org.apache.kafka.common.serialization.ByteArrayDeserializer;
import org.apache.kafka.common.serialization.ByteArraySerializer;
import org.apache.kafka.common.serialization.ByteBufferDeserializer;
import org.apache.kafka.common.serialization.ByteBufferSerializer;
import org.apache.kafka.common.serialization.BytesDeserializer;
import org.apache.kafka.common.serialization.BytesSerializer;
import org.apache.kafka.common.serialization.Deserializer;
import org.apache.kafka.common.serialization.DoubleDeserializer;
import org.apache.kafka.common.serialization.DoubleSerializer;
import org.apache.kafka.common.serialization.FloatDeserializer;
import org.apache.kafka.common.serialization.FloatSerializer;
import org.apache.kafka.common.serialization.IntegerDeserializer;
import org.apache.kafka.common.serialization.IntegerSerializer;
import org.apache.kafka.common.serialization.LongDeserializer;
import org.apache.kafka.common.serialization.LongSerializer;
import org.apache.kafka.common.serialization.Serializer;
import org.apache.kafka.common.serialization.ShortDeserializer;
import org.apache.kafka.common.serialization.ShortSerializer;
import org.apache.kafka.common.serialization.StringDeserializer;
import org.apache.kafka.common.serialization.StringSerializer;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.jboss.shamrock.deployment.annotations.BuildProducer;
import org.jboss.shamrock.deployment.annotations.BuildStep;
import org.jboss.shamrock.deployment.builditem.CombinedIndexBuildItem;
import org.jboss.shamrock.deployment.builditem.substrate.ReflectiveClassBuildItem;

import java.util.Collection;

public class KafkaProcessor {

static final Class[] BUILT_INS = {
//serializers
ShortSerializer.class,
DoubleSerializer.class,
LongSerializer.class,
BytesSerializer.class,
ByteArraySerializer.class,
IntegerSerializer.class,
ByteBufferSerializer.class,
StringSerializer.class,
FloatSerializer.class,

//deserializers
ShortDeserializer.class,
DoubleDeserializer.class,
LongDeserializer.class,
BytesDeserializer.class,
ByteArrayDeserializer.class,
IntegerDeserializer.class,
ByteBufferDeserializer.class,
StringDeserializer.class,
FloatDeserializer.class,
};

@BuildStep
public void build(CombinedIndexBuildItem indexBuildItem, BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {
Collection<ClassInfo> serializers = indexBuildItem.getIndex()
.getAllKnownSubclasses(DotName.createSimple(Serializer.class.getName()));
Collection<ClassInfo> deserializers = indexBuildItem.getIndex()
.getAllKnownSubclasses(DotName.createSimple(Deserializer.class.getName()));

for(Class i : BUILT_INS) {
reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, i.getName()));
}

for (ClassInfo s : serializers) {
reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, s.toString()));
}

for (ClassInfo s : deserializers) {
reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, s.toString()));
}

// Also
// Kafka has is heavily using reflection - at least these 2 classes are instantiated
// The first to produce
// The second to consume
reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, DefaultPartitioner.class.getName()));
reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, RangeAssignor.class.getName()));

}
}
21 changes: 21 additions & 0 deletions extensions/kafka-client/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>shamrock-build-parent</artifactId>
<groupId>org.jboss.shamrock</groupId>
<version>1.0.0.Alpha1-SNAPSHOT</version>
<relativePath>../../build-parent/pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>shamrock-kafka-client</artifactId>
<name>Shamrock - Kafka - Client</name>
<packaging>pom</packaging>

<modules>
<module>deployment</module>
<module>runtime</module>
</modules>
</project>
50 changes: 50 additions & 0 deletions extensions/kafka-client/runtime/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-kafka-client</artifactId>
<version>1.0.0.Alpha1-SNAPSHOT</version>
</parent>

<artifactId>shamrock-kafka-client-runtime</artifactId>

<dependencies>

<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
</dependency>

<dependency>
<groupId>com.oracle.substratevm</groupId>
<artifactId>svm</artifactId>
</dependency>
</dependencies>

<build>
<!-- Mark this as a runtime dependency, so to make sure it's included on the final classpath during native-image -->
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-extension-processor</artifactId>
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>


</project>
2 changes: 2 additions & 0 deletions extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<module>netty</module>
<module>reactive-streams-operators</module>
<module>smallrye-reactive-messaging</module>
<module>smallrye-reactive-messaging-kafka</module>

<!-- Data access and validation -->
<module>narayana-jta</module>
Expand All @@ -65,6 +66,7 @@
<module>hibernate-orm</module>
<module>hibernate-validator</module>
<module>panache</module>
<module>kafka-client</module>

<!-- Spring -->
<module>spring-di</module>
Expand Down
Loading

0 comments on commit e24115b

Please sign in to comment.