You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2019/11/18 09:04:06 UTC
[camel-quarkus] branch master updated: Create a Camel Kafka
extension #142
This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push:
new 9109146 Create a Camel Kafka extension #142
9109146 is described below
commit 910914611bb45ef011ff04d883e607bf4df95ac9
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Sat Nov 16 15:29:32 2019 +0100
Create a Camel Kafka extension #142
---
.../pages/list-of-camel-quarkus-extensions.adoc | 5 +-
extensions/kafka/deployment/pom.xml | 77 ++++++++++++++++++++
.../component/kafka/deployment/KafkaProcessor.java | 29 ++++++++
extensions/kafka/pom.xml | 37 ++++++++++
extensions/kafka/runtime/pom.xml | 84 ++++++++++++++++++++++
.../main/resources/META-INF/quarkus-extension.yaml | 27 +++++++
extensions/pom.xml | 1 +
extensions/readme.adoc | 5 +-
integration-tests/core/test/pom.xml | 4 +-
integration-tests/{core/test => kafka}/pom.xml | 55 +++++++++-----
.../component/kafka/CamelKafkaResource.java | 70 ++++++++++++++++++
.../quarkus/component/kafka/CamelKafkaRoutes.java | 28 ++++++++
.../quarkus/component/kafka/CamelKafkaSupport.java | 60 ++++++++++++++++
.../src/main/resources/application.properties | 30 ++++++++
.../quarkus/component/kafka/it/CamelKafkaIT.java | 23 ++++++
.../quarkus/component/kafka/it/CamelKafkaTest.java | 62 ++++++++++++++++
.../component/kafka/it/CamelKafkaTestResource.java | 59 +++++++++++++++
integration-tests/pom.xml | 6 +-
poms/bom-deployment/pom.xml | 5 ++
poms/bom/pom.xml | 10 +++
20 files changed, 650 insertions(+), 27 deletions(-)
diff --git a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
index 66e1869..f68543b 100644
--- a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
+++ b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
@@ -6,7 +6,7 @@ As of Camel Quarkus {camel-quarkus-last-release} the following Camel artifacts a
== Camel Components
// components: START
-Number of Camel components: 37 in 32 JAR artifacts (0 deprecated)
+Number of Camel components: 38 in 33 JAR artifacts (0 deprecated)
[width="100%",cols="4,1,5",options="header"]
|===
@@ -57,6 +57,9 @@ Number of Camel components: 37 in 32 JAR artifacts (0 deprecated)
| link:https://camel.apache.org/components/latest/jdbc-component.html[JDBC] (camel-quarkus-jdbc) +
`jdbc:dataSourceName` | 0.2 | The jdbc component enables you to access databases through JDBC, where SQL queries are sent in the message body.
+| link:https://camel.apache.org/components/latest/kafka-component.html[Kafka] (camel-quarkus-kafka) +
+`kafka:topic` | 0.5 | The kafka component allows messages to be sent to (or consumed from) Apache Kafka brokers.
+
| link:https://camel.apache.org/components/latest/log-component.html[Log] (camel-quarkus-log) +
`log:loggerName` | 0.2 | The log component logs message exchanges to the underlying logging mechanism.
diff --git a/extensions/kafka/deployment/pom.xml b/extensions/kafka/deployment/pom.xml
new file mode 100644
index 0000000..b90bceb
--- /dev/null
+++ b/extensions/kafka/deployment/pom.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<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.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-kafka-parent</artifactId>
+ <version>0.4.1-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-kafka-deployment</artifactId>
+ <name>Camel Quarkus :: Kafka :: Deployment</name>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bom-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-kafka-client-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-kafka</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/extensions/kafka/deployment/src/main/java/org/apache/camel/quarkus/component/kafka/deployment/KafkaProcessor.java b/extensions/kafka/deployment/src/main/java/org/apache/camel/quarkus/component/kafka/deployment/KafkaProcessor.java
new file mode 100644
index 0000000..a0a5359
--- /dev/null
+++ b/extensions/kafka/deployment/src/main/java/org/apache/camel/quarkus/component/kafka/deployment/KafkaProcessor.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.kafka.deployment;
+
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+
+class KafkaProcessor {
+ private static final String FEATURE = "camel-kafka";
+
+ @BuildStep
+ FeatureBuildItem feature() {
+ return new FeatureBuildItem(FEATURE);
+ }
+}
diff --git a/extensions/kafka/pom.xml b/extensions/kafka/pom.xml
new file mode 100644
index 0000000..737ab26
--- /dev/null
+++ b/extensions/kafka/pom.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<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.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-build-parent</artifactId>
+ <version>0.4.1-SNAPSHOT</version>
+ <relativePath>../../poms/build-parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-kafka-parent</artifactId>
+ <name>Camel Quarkus :: Kafka</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>deployment</module>
+ <module>runtime</module>
+ </modules>
+</project>
diff --git a/extensions/kafka/runtime/pom.xml b/extensions/kafka/runtime/pom.xml
new file mode 100644
index 0000000..deaadd1
--- /dev/null
+++ b/extensions/kafka/runtime/pom.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<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.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-kafka-parent</artifactId>
+ <version>0.4.1-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-kafka</artifactId>
+ <name>Camel Quarkus :: Kafka :: Runtime</name>
+
+ <properties>
+ <firstVersion>0.5.0</firstVersion>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bom</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-kafka-client</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-kafka</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-bootstrap-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/extensions/kafka/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/kafka/runtime/src/main/resources/META-INF/quarkus-extension.yaml
new file mode 100644
index 0000000..c0b6338
--- /dev/null
+++ b/extensions/kafka/runtime/src/main/resources/META-INF/quarkus-extension.yaml
@@ -0,0 +1,27 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+---
+name: "Camel Quarkus Kafka"
+description: "Camel Kafka support"
+metadata:
+ keywords:
+ - "camel"
+ - "kafka"
+ guide: "https://quarkus.io/guides/camel"
+ categories:
+ - "integration"
\ No newline at end of file
diff --git a/extensions/pom.xml b/extensions/pom.xml
index 0c1ba00..7b8e6b6 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -60,6 +60,7 @@
<module>infinispan</module>
<module>jackson</module>
<module>jdbc</module>
+ <module>kafka</module>
<module>log</module>
<module>mail</module>
<module>microprofile-health</module>
diff --git a/extensions/readme.adoc b/extensions/readme.adoc
index b748986..905bbbd 100644
--- a/extensions/readme.adoc
+++ b/extensions/readme.adoc
@@ -5,7 +5,7 @@ Apache Camel Quarkus supports the following Camel artifacts as Quarkus Extension
== Camel Components
// components: START
-Number of Camel components: 37 in 32 JAR artifacts (0 deprecated)
+Number of Camel components: 38 in 33 JAR artifacts (0 deprecated)
[width="100%",cols="4,1,5",options="header"]
|===
@@ -56,6 +56,9 @@ Number of Camel components: 37 in 32 JAR artifacts (0 deprecated)
| link:https://camel.apache.org/components/latest/jdbc-component.html[JDBC] (camel-quarkus-jdbc) +
`jdbc:dataSourceName` | 0.2 | The jdbc component enables you to access databases through JDBC, where SQL queries are sent in the message body.
+| link:https://camel.apache.org/components/latest/kafka-component.html[Kafka] (camel-quarkus-kafka) +
+`kafka:topic` | 0.5 | The kafka component allows messages to be sent to (or consumed from) Apache Kafka brokers.
+
| link:https://camel.apache.org/components/latest/log-component.html[Log] (camel-quarkus-log) +
`log:loggerName` | 0.2 | The log component logs message exchanges to the underlying logging mechanism.
diff --git a/integration-tests/core/test/pom.xml b/integration-tests/core/test/pom.xml
index ef10371..0287f23 100644
--- a/integration-tests/core/test/pom.xml
+++ b/integration-tests/core/test/pom.xml
@@ -52,8 +52,8 @@
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
<dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-jackson</artifactId>
</dependency>
<!-- test dependencies -->
diff --git a/integration-tests/core/test/pom.xml b/integration-tests/kafka/pom.xml
similarity index 75%
copy from integration-tests/core/test/pom.xml
copy to integration-tests/kafka/pom.xml
index ef10371..70d105b 100644
--- a/integration-tests/core/test/pom.xml
+++ b/integration-tests/kafka/pom.xml
@@ -18,42 +18,37 @@
-->
<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.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-integration-test-core-parent</artifactId>
+ <artifactId>camel-quarkus-integration-tests</artifactId>
<version>0.4.1-SNAPSHOT</version>
</parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>camel-quarkus-integration-test-core</artifactId>
- <name>Camel Quarkus :: Integration Tests :: Core :: Tests</name>
- <description>The camel integration tests</description>
+ <artifactId>camel-quarkus-integration-test-kafka</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: Kafka</name>
+ <description>Integration tests for Camel Quarkus Kafka extension</description>
<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-log</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-timer</artifactId>
+ <artifactId>camel-quarkus-kafka</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-integration-test-core-ext</artifactId>
+ <artifactId>camel-quarkus-log</artifactId>
</dependency>
-
<dependency>
<groupId>io.quarkus</groupId>
- <artifactId>quarkus-jsonb</artifactId>
+ <artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
<dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-jackson</artifactId>
</dependency>
<!-- test dependencies -->
@@ -67,7 +62,29 @@
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!-- test dependencies - kafka -->
+ <dependency>
+ <groupId>io.debezium</groupId>
+ <artifactId>debezium-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.debezium</groupId>
+ <artifactId>debezium-core</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.kafka</groupId>
+ <artifactId>kafka_2.12</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
@@ -123,11 +140,14 @@
<goal>native-image</goal>
</goals>
<configuration>
+ <reportErrorsAtRuntime>false</reportErrorsAtRuntime>
<cleanupServer>true</cleanupServer>
- <enableHttpUrlHandler>true</enableHttpUrlHandler>
+ <enableHttpsUrlHandler>true</enableHttpsUrlHandler>
<enableServer>false</enableServer>
<dumpProxies>false</dumpProxies>
- <enableJni>false</enableJni>
+ <graalvmHome>${graalvmHome}</graalvmHome>
+ <enableJni>true</enableJni>
+ <enableAllSecurityServices>true</enableAllSecurityServices>
<disableReports>true</disableReports>
</configuration>
</execution>
@@ -138,5 +158,4 @@
</profile>
</profiles>
-
</project>
diff --git a/integration-tests/kafka/src/main/java/org/apache/camel/quarkus/component/kafka/CamelKafkaResource.java b/integration-tests/kafka/src/main/java/org/apache/camel/quarkus/component/kafka/CamelKafkaResource.java
new file mode 100644
index 0000000..748e82d
--- /dev/null
+++ b/integration-tests/kafka/src/main/java/org/apache/camel/quarkus/component/kafka/CamelKafkaResource.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.kafka;
+
+import java.time.Duration;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.json.Json;
+import javax.json.JsonObject;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.kafka.clients.consumer.ConsumerRecord;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.apache.kafka.clients.producer.RecordMetadata;
+
+@Path("/test")
+@ApplicationScoped
+public class CamelKafkaResource {
+ @Path("/kafka/{topicName}")
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ public JsonObject post(@PathParam("topicName") String topicName, String message) throws Exception {
+ RecordMetadata meta = CamelKafkaSupport.createProducer()
+ .send(new ProducerRecord<>(topicName, 1, message))
+ .get();
+
+ return Json.createObjectBuilder()
+ .add("topicName", meta.topic())
+ .add("partition", meta.partition())
+ .add("offset", meta.offset())
+ .build();
+ }
+
+ @Path("/kafka/{topicName}")
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public JsonObject get(@PathParam("topicName") String topicName) {
+ ConsumerRecord<Integer, String> record = CamelKafkaSupport.createConsumer(topicName)
+ .poll(Duration.ofSeconds(60))
+ .iterator()
+ .next();
+
+ return Json.createObjectBuilder()
+ .add("topicName", record.topic())
+ .add("partition", record.partition())
+ .add("offset", record.offset())
+ .add("key", record.key())
+ .add("body", record.value())
+ .build();
+ }
+}
diff --git a/integration-tests/kafka/src/main/java/org/apache/camel/quarkus/component/kafka/CamelKafkaRoutes.java b/integration-tests/kafka/src/main/java/org/apache/camel/quarkus/component/kafka/CamelKafkaRoutes.java
new file mode 100644
index 0000000..d8b2831
--- /dev/null
+++ b/integration-tests/kafka/src/main/java/org/apache/camel/quarkus/component/kafka/CamelKafkaRoutes.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.kafka;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class CamelKafkaRoutes extends RouteBuilder {
+ @Override
+ public void configure() throws Exception {
+ from("kafka:inbound")
+ .to("log:kafka")
+ .to("kafka:outbound");
+ }
+}
diff --git a/integration-tests/kafka/src/main/java/org/apache/camel/quarkus/component/kafka/CamelKafkaSupport.java b/integration-tests/kafka/src/main/java/org/apache/camel/quarkus/component/kafka/CamelKafkaSupport.java
new file mode 100644
index 0000000..baa2eee
--- /dev/null
+++ b/integration-tests/kafka/src/main/java/org/apache/camel/quarkus/component/kafka/CamelKafkaSupport.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.kafka;
+
+import java.util.Collections;
+import java.util.Properties;
+
+import org.apache.kafka.clients.consumer.ConsumerConfig;
+import org.apache.kafka.clients.consumer.KafkaConsumer;
+import org.apache.kafka.clients.producer.KafkaProducer;
+import org.apache.kafka.clients.producer.Producer;
+import org.apache.kafka.clients.producer.ProducerConfig;
+import org.apache.kafka.common.serialization.IntegerDeserializer;
+import org.apache.kafka.common.serialization.IntegerSerializer;
+import org.apache.kafka.common.serialization.StringDeserializer;
+import org.apache.kafka.common.serialization.StringSerializer;
+
+public final class CamelKafkaSupport {
+ private CamelKafkaSupport() {
+ }
+
+ public static KafkaConsumer<Integer, String> createConsumer(String topicName) {
+ Properties props = new Properties();
+ props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:19092");
+ props.put(ConsumerConfig.GROUP_ID_CONFIG, "test");
+ props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, IntegerDeserializer.class.getName());
+ props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
+ props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "true");
+ props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
+
+ KafkaConsumer<Integer, String> consumer = new KafkaConsumer<>(props);
+ consumer.subscribe(Collections.singletonList(topicName));
+
+ return consumer;
+ }
+
+ public static Producer<Integer, String> createProducer() {
+ Properties props = new Properties();
+ props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:19092");
+ props.put(ProducerConfig.CLIENT_ID_CONFIG, "test-consumer");
+ props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, IntegerSerializer.class.getName());
+ props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
+
+ return new KafkaProducer<>(props);
+ }
+}
diff --git a/integration-tests/kafka/src/main/resources/application.properties b/integration-tests/kafka/src/main/resources/application.properties
new file mode 100644
index 0000000..a41a269
--- /dev/null
+++ b/integration-tests/kafka/src/main/resources/application.properties
@@ -0,0 +1,30 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+#
+# Quarkus
+#
+quarkus.log.file.enable = false
+quarkus.log.category."org.apache.camel.quarkus.core.deployment".level = INFO
+quarkus.log.category."org.apache.camel.quarkus.component.kafka".level = DEBUG
+quarkus.log.category."org.apache.zookeeper".level = WARNING
+quarkus.log.category."org.apache.kafka".level = WARNING
+
+#
+# Camel
+#
+camel.component.kafka.brokers = localhost:19092
\ No newline at end of file
diff --git a/integration-tests/kafka/src/test/java/org/apache/camel/quarkus/component/kafka/it/CamelKafkaIT.java b/integration-tests/kafka/src/test/java/org/apache/camel/quarkus/component/kafka/it/CamelKafkaIT.java
new file mode 100644
index 0000000..39ac37e
--- /dev/null
+++ b/integration-tests/kafka/src/test/java/org/apache/camel/quarkus/component/kafka/it/CamelKafkaIT.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.kafka.it;
+
+import io.quarkus.test.junit.NativeImageTest;
+
+@NativeImageTest
+public class CamelKafkaIT extends CamelKafkaTest {
+}
diff --git a/integration-tests/kafka/src/test/java/org/apache/camel/quarkus/component/kafka/it/CamelKafkaTest.java b/integration-tests/kafka/src/test/java/org/apache/camel/quarkus/component/kafka/it/CamelKafkaTest.java
new file mode 100644
index 0000000..2e4ba04
--- /dev/null
+++ b/integration-tests/kafka/src/test/java/org/apache/camel/quarkus/component/kafka/it/CamelKafkaTest.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.kafka.it;
+
+import java.util.UUID;
+
+import javax.inject.Inject;
+
+import org.apache.camel.quarkus.core.CamelMain;
+import org.junit.jupiter.api.Test;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.path.json.JsonPath;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@QuarkusTest
+@QuarkusTestResource(CamelKafkaTestResource.class)
+public class CamelKafkaTest {
+
+ @Inject
+ CamelMain main;
+
+ @Test
+ void testKafkaBridge() {
+ String body = UUID.randomUUID().toString();
+
+ RestAssured.given()
+ .contentType("text/plain")
+ .body(body)
+ .post("/test/kafka/inbound")
+ .then()
+ .statusCode(200);
+
+ JsonPath result = RestAssured.given()
+ .get("/test/kafka/outbound")
+ .then()
+ .statusCode(200)
+ .extract()
+ .body()
+ .jsonPath();
+
+ assertThat(result.getString("topicName")).isEqualTo("outbound");
+ assertThat(result.getString("body")).isEqualTo(body);
+ }
+}
diff --git a/integration-tests/kafka/src/test/java/org/apache/camel/quarkus/component/kafka/it/CamelKafkaTestResource.java b/integration-tests/kafka/src/test/java/org/apache/camel/quarkus/component/kafka/it/CamelKafkaTestResource.java
new file mode 100644
index 0000000..d33a466
--- /dev/null
+++ b/integration-tests/kafka/src/test/java/org/apache/camel/quarkus/component/kafka/it/CamelKafkaTestResource.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.kafka.it;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Properties;
+
+import io.debezium.kafka.KafkaCluster;
+import io.debezium.util.Testing;
+import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
+
+public class CamelKafkaTestResource implements QuarkusTestResourceLifecycleManager {
+ private KafkaCluster kafka;
+
+ @Override
+ public Map<String, String> start() {
+ try {
+ Properties props = new Properties();
+ props.setProperty("zookeeper.connection.timeout.ms", "45000");
+
+ File directory = Testing.Files.createTestingDirectory("kafka-data", true);
+
+ kafka = new KafkaCluster()
+ .withPorts(2182, 19092)
+ .addBrokers(1)
+ .usingDirectory(directory)
+ .deleteDataUponShutdown(true)
+ .withKafkaConfiguration(props)
+ .deleteDataPriorToStartup(true)
+ .startup();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ return Collections.emptyMap();
+ }
+
+ @Override
+ public void stop() {
+ if (kafka != null) {
+ kafka.shutdown();
+ }
+ }
+}
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index d5c0b15..06a4732 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -65,11 +65,6 @@
<artifactId>activemq-broker</artifactId>
<version>${activemq-version}</version>
</dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- <version>2.9.10</version>
- </dependency>
</dependencies>
</dependencyManagement>
@@ -91,6 +86,7 @@
<module>infinispan</module>
<module>jackson</module>
<module>jdbc</module>
+ <module>kafka</module>
<module>mail</module>
<module>microprofile</module>
<module>netty</module>
diff --git a/poms/bom-deployment/pom.xml b/poms/bom-deployment/pom.xml
index c629df8..75349ab 100644
--- a/poms/bom-deployment/pom.xml
+++ b/poms/bom-deployment/pom.xml
@@ -180,6 +180,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-kafka-deployment</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-log-deployment</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>
diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml
index c9d10cb..9dbaf95 100644
--- a/poms/bom/pom.xml
+++ b/poms/bom/pom.xml
@@ -187,6 +187,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-kafka</artifactId>
+ <version>${camel.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-log</artifactId>
<version>${camel.version}</version>
</dependency>
@@ -470,6 +475,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-kafka</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-log</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>