This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 0662dd6fdc1a3a2a8ae0e0ac36586ea84f127d85 Author: James Netherton <[email protected]> AuthorDate: Mon Jan 11 10:54:43 2021 +0000 Add vertx-kafka component support Fixes #2082 --- catalog/pom.xml | 13 ++ .../pages/reference/extensions/vertx-kafka.adoc | 33 +++++ .../partials/reference/components/vertx-kafka.adoc | 14 +- extensions/pom.xml | 1 + extensions/vertx-kafka/deployment/pom.xml | 71 +++++++++++ .../kafka/deployment/VertxKafkaProcessor.java | 43 +++++++ extensions/vertx-kafka/pom.xml | 39 ++++++ extensions/vertx-kafka/runtime/pom.xml | 121 ++++++++++++++++++ .../vertx/kafka/CamelVertxKafkaRecorder.java | 32 +++++ .../main/resources/META-INF/quarkus-extension.yaml | 31 +++++ integration-tests/pom.xml | 1 + integration-tests/vertx-kafka/pom.xml | 142 +++++++++++++++++++++ .../vertx/kafka/it/VertxKafkaProducers.java | 70 ++++++++++ .../vertx/kafka/it/VertxKafkaResource.java | 73 +++++++++++ .../component/vertx/kafka/it/VertxKafkaRoutes.java | 30 +++++ .../component/vertx/kafka/it/VertxKafkaIT.java | 24 ++++ .../component/vertx/kafka/it/VertxKafkaTest.java | 48 +++++++ .../vertx/kafka/it/VertxKafkaTestResource.java | 59 +++++++++ poms/bom/pom.xml | 15 +++ tooling/scripts/test-categories.yaml | 1 + 20 files changed, 860 insertions(+), 1 deletion(-) diff --git a/catalog/pom.xml b/catalog/pom.xml index feaa238..113a81d 100644 --- a/catalog/pom.xml +++ b/catalog/pom.xml @@ -3988,6 +3988,19 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-vertx-kafka</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-vertx-websocket</artifactId> <version>${project.version}</version> <type>pom</type> diff --git a/docs/modules/ROOT/pages/reference/extensions/vertx-kafka.adoc b/docs/modules/ROOT/pages/reference/extensions/vertx-kafka.adoc new file mode 100644 index 0000000..b96a175 --- /dev/null +++ b/docs/modules/ROOT/pages/reference/extensions/vertx-kafka.adoc @@ -0,0 +1,33 @@ +// Do not edit directly! +// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page += Vert.x Kafka +:cq-artifact-id: camel-quarkus-vertx-kafka +:cq-native-supported: true +:cq-status: Stable +:cq-description: Sent and receive messages to/from an Apache Kafka broker using vert.x Kafka client +:cq-deprecated: false +:cq-jvm-since: 1.6.0 +:cq-native-since: 1.6.0 + +[.badges] +[.badge-key]##JVM since##[.badge-supported]##1.6.0## [.badge-key]##Native since##[.badge-supported]##1.6.0## + +Sent and receive messages to/from an Apache Kafka broker using vert.x Kafka client + +== What's inside + +* xref:{cq-camel-components}::vertx-kafka-component.adoc[Vert.x Kafka component], URI syntax: `vertx-kafka:topic` + +Please refer to the above link for usage and configuration details. + +== Maven coordinates + +[source,xml] +---- +<dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-vertx-kafka</artifactId> +</dependency> +---- + +Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications. diff --git a/docs/modules/ROOT/partials/reference/components/vertx-kafka.adoc b/docs/modules/ROOT/partials/reference/components/vertx-kafka.adoc index a509c1d..65e36d2 100644 --- a/docs/modules/ROOT/partials/reference/components/vertx-kafka.adoc +++ b/docs/modules/ROOT/partials/reference/components/vertx-kafka.adoc @@ -1 +1,13 @@ -// Empty partial for a Camel bit unsupported by Camel Quarkus to avoid warnings when this file is included from a Camel page +// Do not edit directly! +// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page +:cq-artifact-id: camel-quarkus-vertx-kafka +:cq-artifact-id-base: vertx-kafka +:cq-native-supported: true +:cq-status: Stable +:cq-deprecated: false +:cq-jvm-since: 1.6.0 +:cq-native-since: 1.6.0 +:cq-camel-part-name: vertx-kafka +:cq-camel-part-title: Vert.x Kafka +:cq-camel-part-description: Sent and receive messages to/from an Apache Kafka broker using vert.x Kafka client +:cq-extension-page-title: Vert.x Kafka diff --git a/extensions/pom.xml b/extensions/pom.xml index 6ea25f0..728fcf0 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -218,6 +218,7 @@ <module>velocity</module> <module>vertx</module> <module>vertx-http</module> + <module>vertx-kafka</module> <module>vertx-websocket</module> <module>vm</module> <module>weather</module> diff --git a/extensions/vertx-kafka/deployment/pom.xml b/extensions/vertx-kafka/deployment/pom.xml new file mode 100644 index 0000000..3e93e2f --- /dev/null +++ b/extensions/vertx-kafka/deployment/pom.xml @@ -0,0 +1,71 @@ +<?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-vertx-kafka-parent</artifactId> + <version>1.6.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-vertx-kafka-deployment</artifactId> + <name>Camel Quarkus :: Vert.x Kafka :: Deployment</name> + + <dependencies> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-vertx-deployment</artifactId> + </dependency> + <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-vertx-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/vertx-kafka/deployment/src/main/java/org/apache/camel/quarkus/component/vertx/kafka/deployment/VertxKafkaProcessor.java b/extensions/vertx-kafka/deployment/src/main/java/org/apache/camel/quarkus/component/vertx/kafka/deployment/VertxKafkaProcessor.java new file mode 100644 index 0000000..ec326dc --- /dev/null +++ b/extensions/vertx-kafka/deployment/src/main/java/org/apache/camel/quarkus/component/vertx/kafka/deployment/VertxKafkaProcessor.java @@ -0,0 +1,43 @@ +/* + * 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.vertx.kafka.deployment; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.annotations.ExecutionTime; +import io.quarkus.deployment.annotations.Record; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.vertx.deployment.VertxBuildItem; +import org.apache.camel.component.vertx.kafka.VertxKafkaComponent; +import org.apache.camel.quarkus.component.vertx.kafka.CamelVertxKafkaRecorder; +import org.apache.camel.quarkus.core.deployment.spi.CamelRuntimeBeanBuildItem; + +class VertxKafkaProcessor { + + private static final String FEATURE = "camel-vertx-kafka"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + @Record(ExecutionTime.RUNTIME_INIT) + @BuildStep + CamelRuntimeBeanBuildItem configureVertxKafkaComponent(CamelVertxKafkaRecorder recorder, VertxBuildItem vertx) { + return new CamelRuntimeBeanBuildItem("vertx-kafka", VertxKafkaComponent.class.getName(), + recorder.createVertxKafkaComponent(vertx.getVertx())); + } +} diff --git a/extensions/vertx-kafka/pom.xml b/extensions/vertx-kafka/pom.xml new file mode 100644 index 0000000..edbaee1 --- /dev/null +++ b/extensions/vertx-kafka/pom.xml @@ -0,0 +1,39 @@ +<?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>1.6.0-SNAPSHOT</version> + <relativePath>../../poms/build-parent/pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-vertx-kafka-parent</artifactId> + <name>Camel Quarkus :: Vert.x Kafka</name> + <packaging>pom</packaging> + + <modules> + <module>deployment</module> + <module>runtime</module> + </modules> +</project> diff --git a/extensions/vertx-kafka/runtime/pom.xml b/extensions/vertx-kafka/runtime/pom.xml new file mode 100644 index 0000000..2b394ac --- /dev/null +++ b/extensions/vertx-kafka/runtime/pom.xml @@ -0,0 +1,121 @@ +<?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-vertx-kafka-parent</artifactId> + <version>1.6.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-vertx-kafka</artifactId> + <name>Camel Quarkus :: Vert.x Kafka :: Runtime</name> + <description>Sent and receive messages to/from an Apache Kafka broker using vert.x Kafka client</description> + + <properties> + <camel.quarkus.jvmSince>1.6.0</camel.quarkus.jvmSince> + <camel.quarkus.nativeSince>1.6.0</camel.quarkus.nativeSince> + </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-vertx</artifactId> + </dependency> + <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-vertx-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> + + + <profiles> + <profile> + <id>full</id> + <activation> + <property> + <name>!quickly</name> + </property> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-maven-plugin</artifactId> + <executions> + <execution> + <id>update-extension-doc-page</id> + <goals> + <goal>update-extension-doc-page</goal> + </goals> + <phase>process-classes</phase> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> diff --git a/extensions/vertx-kafka/runtime/src/main/java/org/apache/camel/quarkus/component/vertx/kafka/CamelVertxKafkaRecorder.java b/extensions/vertx-kafka/runtime/src/main/java/org/apache/camel/quarkus/component/vertx/kafka/CamelVertxKafkaRecorder.java new file mode 100644 index 0000000..a34f8e8 --- /dev/null +++ b/extensions/vertx-kafka/runtime/src/main/java/org/apache/camel/quarkus/component/vertx/kafka/CamelVertxKafkaRecorder.java @@ -0,0 +1,32 @@ +/* + * 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.vertx.kafka; + +import io.quarkus.runtime.RuntimeValue; +import io.quarkus.runtime.annotations.Recorder; +import io.vertx.core.Vertx; +import org.apache.camel.component.vertx.kafka.VertxKafkaComponent; + +@Recorder +public class CamelVertxKafkaRecorder { + + public RuntimeValue<?> createVertxKafkaComponent(RuntimeValue<Vertx> vertx) { + VertxKafkaComponent component = new VertxKafkaComponent(); + component.setVertx(vertx.getValue()); + return new RuntimeValue<>(component); + } +} diff --git a/extensions/vertx-kafka/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/vertx-kafka/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000..16b3847 --- /dev/null +++ b/extensions/vertx-kafka/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,31 @@ +# +# 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. +# + +# This is a generated file. Do not edit directly! +# To re-generate, run the following command from the top level directory: +# +# mvn -N cq:update-quarkus-metadata +# +--- +name: "Camel Vert.x Kafka" +description: "Sent and receive messages to/from an Apache Kafka broker using vert.x Kafka client" +metadata: + guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/vertx-kafka.html" + categories: + - "integration" + status: + - "stable" diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 1b8897d..f838567 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -182,6 +182,7 @@ <module>validator</module> <module>velocity</module> <module>vertx</module> + <module>vertx-kafka</module> <module>vertx-websocket</module> <module>weather</module> <module>websocket-jsr356</module> diff --git a/integration-tests/vertx-kafka/pom.xml b/integration-tests/vertx-kafka/pom.xml new file mode 100644 index 0000000..c767d76 --- /dev/null +++ b/integration-tests/vertx-kafka/pom.xml @@ -0,0 +1,142 @@ +<?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-integration-tests</artifactId> + <version>1.6.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-integration-test-vertx-kafka</artifactId> + <name>Camel Quarkus :: Integration Tests :: Vert.x Kafka</name> + <description>Integration tests for Camel Quarkus Vert.x Kafka extension</description> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-bom-test</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-main</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-vertx-kafka</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy</artifactId> + </dependency> + + <!-- test dependencies --> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-junit5</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.rest-assured</groupId> + <artifactId>rest-assured</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-integration-testcontainers-support</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.testcontainers</groupId> + <artifactId>kafka</artifactId> + <scope>test</scope> + </dependency> + + <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory --> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-main-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-vertx-kafka-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> + + <profiles> + <profile> + <id>native</id> + <activation> + <property> + <name>native</name> + </property> + </activation> + <properties> + <quarkus.package.type>native</quarkus.package.type> + </properties> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> + +</project> diff --git a/integration-tests/vertx-kafka/src/main/java/org/apache/camel/quarkus/component/vertx/kafka/it/VertxKafkaProducers.java b/integration-tests/vertx-kafka/src/main/java/org/apache/camel/quarkus/component/vertx/kafka/it/VertxKafkaProducers.java new file mode 100644 index 0000000..4ad0be0 --- /dev/null +++ b/integration-tests/vertx-kafka/src/main/java/org/apache/camel/quarkus/component/vertx/kafka/it/VertxKafkaProducers.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.vertx.kafka.it; + +import java.util.HashMap; +import java.util.Map; + +import javax.enterprise.inject.Produces; +import javax.inject.Singleton; + +import io.vertx.core.Vertx; +import io.vertx.kafka.client.consumer.KafkaConsumer; +import io.vertx.kafka.client.producer.KafkaProducer; +import org.apache.kafka.clients.consumer.ConsumerConfig; +import org.apache.kafka.clients.producer.ProducerConfig; +import org.apache.kafka.clients.producer.internals.DefaultPartitioner; +import org.apache.kafka.common.serialization.StringDeserializer; +import org.apache.kafka.common.serialization.StringSerializer; + +public class VertxKafkaProducers { + + public static final String GROUP_ID = "camel-quarkus-group"; + public static final String TOPIC_INBOUND = "inbound"; + public static final String TOPIC_OUTBOUND = "outbound"; + + @Produces + @Singleton + public KafkaConsumer<String, String> createKafkaConsumer(Vertx vertx) { + Map<String, String> config = new HashMap<>(); + config.put(ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG, "1000"); + config.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"); + config.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, + System.getProperty("camel.component.vertx-kafka.bootstrap-servers")); + config.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "true"); + config.put(ConsumerConfig.GROUP_ID_CONFIG, GROUP_ID); + config.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName()); + config.put(ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, "30000"); + config.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName()); + + KafkaConsumer<String, String> consumer = KafkaConsumer.create(vertx, config); + return consumer.subscribe(TOPIC_OUTBOUND); + } + + @Produces + @Singleton + public KafkaProducer<String, String> createKafkaProducer(Vertx vertx) { + Map<String, String> config = new HashMap<>(); + config.put(ProducerConfig.ACKS_CONFIG, "1"); + config.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, + System.getProperty("camel.component.vertx-kafka.bootstrap-servers")); + config.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName()); + config.put(ProducerConfig.PARTITIONER_CLASS_CONFIG, DefaultPartitioner.class.getName()); + config.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName()); + return KafkaProducer.create(vertx, config); + } +} diff --git a/integration-tests/vertx-kafka/src/main/java/org/apache/camel/quarkus/component/vertx/kafka/it/VertxKafkaResource.java b/integration-tests/vertx-kafka/src/main/java/org/apache/camel/quarkus/component/vertx/kafka/it/VertxKafkaResource.java new file mode 100644 index 0000000..c643294 --- /dev/null +++ b/integration-tests/vertx-kafka/src/main/java/org/apache/camel/quarkus/component/vertx/kafka/it/VertxKafkaResource.java @@ -0,0 +1,73 @@ +/* + * 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.vertx.kafka.it; + +import java.net.URI; +import java.time.Duration; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; + +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import io.vertx.kafka.client.consumer.KafkaConsumer; +import io.vertx.kafka.client.consumer.KafkaConsumerRecords; +import io.vertx.kafka.client.producer.KafkaProducer; +import io.vertx.kafka.client.producer.KafkaProducerRecord; +import org.apache.kafka.clients.consumer.ConsumerRecord; + +@Path("/vertx-kafka") +public class VertxKafkaResource { + + @Inject + KafkaConsumer<String, String> kafkaConsumer; + + @Inject + KafkaProducer<String, String> kafkaProducer; + + @Path("/get") + @GET + @Produces(MediaType.TEXT_PLAIN) + public String get() throws Exception { + CompletableFuture<String> result = new CompletableFuture<>(); + kafkaConsumer.poll(Duration.ofSeconds(10), asyncResult -> { + if (asyncResult.succeeded()) { + KafkaConsumerRecords<String, String> consumerRecords = asyncResult.result(); + ConsumerRecord<String, String> record = consumerRecords.records().iterator().next(); + result.complete(record.value()); + } else { + result.completeExceptionally(asyncResult.cause()); + } + }); + return result.get(15, TimeUnit.SECONDS); + } + + @Path("/post") + @POST + @Consumes(MediaType.TEXT_PLAIN) + public Response post(String message) throws Exception { + KafkaProducerRecord<String, String> record = KafkaProducerRecord.create(VertxKafkaProducers.TOPIC_INBOUND, message); + kafkaProducer.send(record); + return Response.created(new URI("https://camel.apache.org/")).build(); + } +} diff --git a/integration-tests/vertx-kafka/src/main/java/org/apache/camel/quarkus/component/vertx/kafka/it/VertxKafkaRoutes.java b/integration-tests/vertx-kafka/src/main/java/org/apache/camel/quarkus/component/vertx/kafka/it/VertxKafkaRoutes.java new file mode 100644 index 0000000..15f3f38 --- /dev/null +++ b/integration-tests/vertx-kafka/src/main/java/org/apache/camel/quarkus/component/vertx/kafka/it/VertxKafkaRoutes.java @@ -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. + */ +package org.apache.camel.quarkus.component.vertx.kafka.it; + +import org.apache.camel.builder.RouteBuilder; + +import static org.apache.camel.quarkus.component.vertx.kafka.it.VertxKafkaProducers.GROUP_ID; + +public class VertxKafkaRoutes extends RouteBuilder { + @Override + public void configure() throws Exception { + fromF("vertx-kafka:inbound?groupId=%s", GROUP_ID) + .removeHeaders("CamelVertxKafka.*") + .to("vertx-kafka:outbound?acks=-1"); + } +} diff --git a/integration-tests/vertx-kafka/src/test/java/org/apache/camel/quarkus/component/vertx/kafka/it/VertxKafkaIT.java b/integration-tests/vertx-kafka/src/test/java/org/apache/camel/quarkus/component/vertx/kafka/it/VertxKafkaIT.java new file mode 100644 index 0000000..b969afc --- /dev/null +++ b/integration-tests/vertx-kafka/src/test/java/org/apache/camel/quarkus/component/vertx/kafka/it/VertxKafkaIT.java @@ -0,0 +1,24 @@ +/* + * 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.vertx.kafka.it; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +class VertxKafkaIT extends VertxKafkaTest { + +} diff --git a/integration-tests/vertx-kafka/src/test/java/org/apache/camel/quarkus/component/vertx/kafka/it/VertxKafkaTest.java b/integration-tests/vertx-kafka/src/test/java/org/apache/camel/quarkus/component/vertx/kafka/it/VertxKafkaTest.java new file mode 100644 index 0000000..28c459f --- /dev/null +++ b/integration-tests/vertx-kafka/src/test/java/org/apache/camel/quarkus/component/vertx/kafka/it/VertxKafkaTest.java @@ -0,0 +1,48 @@ +/* + * 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.vertx.kafka.it; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.CoreMatchers.is; + +@QuarkusTest +@QuarkusTestResource(VertxKafkaTestResource.class) +class VertxKafkaTest { + + @Test + public void testVertxKafka() { + String message = "Hello Camel Quarkus Vert.x Kafka"; + + RestAssured.given() + .contentType(ContentType.TEXT) + .body(message) + .post("/vertx-kafka/post") + .then() + .statusCode(201); + + RestAssured.given() + .get("/vertx-kafka/get") + .then() + .statusCode(200) + .body(is(message)); + } +} diff --git a/integration-tests/vertx-kafka/src/test/java/org/apache/camel/quarkus/component/vertx/kafka/it/VertxKafkaTestResource.java b/integration-tests/vertx-kafka/src/test/java/org/apache/camel/quarkus/component/vertx/kafka/it/VertxKafkaTestResource.java new file mode 100644 index 0000000..eeef17d --- /dev/null +++ b/integration-tests/vertx-kafka/src/test/java/org/apache/camel/quarkus/component/vertx/kafka/it/VertxKafkaTestResource.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.vertx.kafka.it; + +import java.util.Collections; +import java.util.Map; + +import org.apache.camel.quarkus.testcontainers.ContainerResourceLifecycleManager; +import org.testcontainers.containers.KafkaContainer; +import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.utility.DockerImageName; + +public class VertxKafkaTestResource implements ContainerResourceLifecycleManager { + + private static final String KAFKA_IMAGE_NAME = "confluentinc/cp-kafka:5.4.3"; + private KafkaContainer container; + + @Override + public Map<String, String> start() { + try { + DockerImageName imageName = DockerImageName.parse(KAFKA_IMAGE_NAME); + + container = new KafkaContainer(imageName) + .withEmbeddedZookeeper() + .waitingFor(Wait.forListeningPort()); + + container.start(); + + return Collections.singletonMap("camel.component.vertx-kafka.bootstrap-servers", container.getBootstrapServers()); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public void stop() { + if (container != null) { + try { + container.stop(); + } catch (Exception e) { + // ignored + } + } + } +} diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index c531eab..b1059a5 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -1972,6 +1972,11 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> + <artifactId>camel-vertx-kafka</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> <artifactId>camel-vertx-websocket</artifactId> <version>${camel.version}</version> </dependency> @@ -5144,6 +5149,16 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-vertx-kafka</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-vertx-kafka-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-vertx-websocket</artifactId> <version>${camel-quarkus.version}</version> </dependency> diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml index 726e84b..e71637d 100644 --- a/tooling/scripts/test-categories.yaml +++ b/tooling/scripts/test-categories.yaml @@ -115,6 +115,7 @@ messaging-networking1: - rabbitmq - ftp - graphql + - vertx-kafka - vertx-websocket misc: - braintree
