This is an automated email from the ASF dual-hosted git repository. ppalaga pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 798aff65b13ce2f19b8aa5611b6c8df2fc8f981e Author: Peter Palaga <ppal...@redhat.com> AuthorDate: Tue Mar 2 21:57:00 2021 +0100 Paho MQTT 5 support #2145 --- catalog/pom.xml | 39 +++++++ .../pages/reference/extensions/paho-mqtt5.adoc | 33 ++++++ .../partials/reference/components/paho-mqtt5.adoc | 14 ++- extensions/paho-mqtt5/deployment/pom.xml | 63 +++++++++++ .../paho/mqtt5/deployment/PahoMqtt5Processor.java | 60 +++++++++++ extensions/paho-mqtt5/pom.xml | 39 +++++++ extensions/paho-mqtt5/runtime/pom.xml | 113 +++++++++++++++++++ .../main/resources/META-INF/quarkus-extension.yaml | 31 ++++++ extensions/pom.xml | 1 + integration-tests/paho-mqtt5/pom.xml | 120 +++++++++++++++++++++ .../component/paho/mqtt5/it/PahoMqtt5Resource.java | 71 ++++++++++++ .../component/paho/mqtt5/it/PahoMqtt5IT.java | 24 +++++ .../component/paho/mqtt5/it/PahoMqtt5Test.java | 52 +++++++++ .../paho/mqtt5/it/PahoMqtt5TestResource.java | 69 ++++++++++++ integration-tests/pom.xml | 1 + poms/bom/pom.xml | 15 +++ tooling/scripts/test-categories.yaml | 1 + 17 files changed, 745 insertions(+), 1 deletion(-) diff --git a/catalog/pom.xml b/catalog/pom.xml index 792adc3..e478b8b 100644 --- a/catalog/pom.xml +++ b/catalog/pom.xml @@ -1856,6 +1856,19 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-huaweicloud-smn</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-hystrix</artifactId> <version>${project.version}</version> <type>pom</type> @@ -2935,6 +2948,19 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-paho-mqtt5</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-pdf</artifactId> <version>${project.version}</version> <type>pom</type> @@ -3572,6 +3598,19 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-stitch</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-stomp</artifactId> <version>${project.version}</version> <type>pom</type> diff --git a/docs/modules/ROOT/pages/reference/extensions/paho-mqtt5.adoc b/docs/modules/ROOT/pages/reference/extensions/paho-mqtt5.adoc new file mode 100644 index 0000000..b2ee099 --- /dev/null +++ b/docs/modules/ROOT/pages/reference/extensions/paho-mqtt5.adoc @@ -0,0 +1,33 @@ +// Do not edit directly! +// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page += Paho MQTT5 +:cq-artifact-id: camel-quarkus-paho-mqtt5 +:cq-native-supported: true +:cq-status: Stable +:cq-description: Communicate with MQTT message brokers using Eclipse Paho MQTT v5 Client. +:cq-deprecated: false +:cq-jvm-since: 1.8.0 +:cq-native-since: 1.8.0 + +[.badges] +[.badge-key]##JVM since##[.badge-supported]##1.8.0## [.badge-key]##Native since##[.badge-supported]##1.8.0## + +Communicate with MQTT message brokers using Eclipse Paho MQTT v5 Client. + +== What's inside + +* xref:{cq-camel-components}::paho-mqtt5-component.adoc[Paho MQTT 5 component], URI syntax: `paho-mqtt5: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-paho-mqtt5</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/paho-mqtt5.adoc b/docs/modules/ROOT/partials/reference/components/paho-mqtt5.adoc index a509c1d..6dfee05 100644 --- a/docs/modules/ROOT/partials/reference/components/paho-mqtt5.adoc +++ b/docs/modules/ROOT/partials/reference/components/paho-mqtt5.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-paho-mqtt5 +:cq-artifact-id-base: paho-mqtt5 +:cq-native-supported: true +:cq-status: Stable +:cq-deprecated: false +:cq-jvm-since: 1.8.0 +:cq-native-since: 1.8.0 +:cq-camel-part-name: paho-mqtt5 +:cq-camel-part-title: Paho MQTT 5 +:cq-camel-part-description: Communicate with MQTT message brokers using Eclipse Paho MQTT v5 Client. +:cq-extension-page-title: Paho MQTT5 diff --git a/extensions/paho-mqtt5/deployment/pom.xml b/extensions/paho-mqtt5/deployment/pom.xml new file mode 100644 index 0000000..147abf0 --- /dev/null +++ b/extensions/paho-mqtt5/deployment/pom.xml @@ -0,0 +1,63 @@ +<?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-paho-mqtt5-parent</artifactId> + <version>1.8.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-paho-mqtt5-deployment</artifactId> + <name>Camel Quarkus :: Paho MQTT5 :: Deployment</name> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-paho-mqtt5</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/paho-mqtt5/deployment/src/main/java/org/apache/camel/quarkus/component/paho/mqtt5/deployment/PahoMqtt5Processor.java b/extensions/paho-mqtt5/deployment/src/main/java/org/apache/camel/quarkus/component/paho/mqtt5/deployment/PahoMqtt5Processor.java new file mode 100644 index 0000000..17fc9f2 --- /dev/null +++ b/extensions/paho-mqtt5/deployment/src/main/java/org/apache/camel/quarkus/component/paho/mqtt5/deployment/PahoMqtt5Processor.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.paho.mqtt5.deployment; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBundleBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem; +import org.eclipse.paho.mqttv5.client.internal.SSLNetworkModuleFactory; +import org.eclipse.paho.mqttv5.client.internal.TCPNetworkModuleFactory; +import org.eclipse.paho.mqttv5.client.logging.JSR47Logger; +import org.eclipse.paho.mqttv5.client.spi.NetworkModuleFactory; +import org.eclipse.paho.mqttv5.client.websocket.WebSocketNetworkModuleFactory; +import org.eclipse.paho.mqttv5.client.websocket.WebSocketSecureNetworkModuleFactory; + +class PahoMqtt5Processor { + + private static final String FEATURE = "camel-paho-mqtt5"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + @BuildStep + ReflectiveClassBuildItem registerReflectiveClasses() { + return new ReflectiveClassBuildItem(false, false, JSR47Logger.class); + } + + @BuildStep + ServiceProviderBuildItem registerServiceProviders() { + return new ServiceProviderBuildItem( + NetworkModuleFactory.class.getName(), + TCPNetworkModuleFactory.class.getName(), + SSLNetworkModuleFactory.class.getName(), + WebSocketNetworkModuleFactory.class.getName(), + WebSocketSecureNetworkModuleFactory.class.getName()); + } + + @BuildStep() + NativeImageResourceBundleBuildItem hapiMessages() { + return new NativeImageResourceBundleBuildItem("org.eclipse.paho.mqttv5.client.internal.nls.logcat"); + } + +} diff --git a/extensions/paho-mqtt5/pom.xml b/extensions/paho-mqtt5/pom.xml new file mode 100644 index 0000000..259a277 --- /dev/null +++ b/extensions/paho-mqtt5/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.8.0-SNAPSHOT</version> + <relativePath>../../poms/build-parent/pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-paho-mqtt5-parent</artifactId> + <name>Camel Quarkus :: Paho MQTT5</name> + <packaging>pom</packaging> + + <modules> + <module>deployment</module> + <module>runtime</module> + </modules> +</project> diff --git a/extensions/paho-mqtt5/runtime/pom.xml b/extensions/paho-mqtt5/runtime/pom.xml new file mode 100644 index 0000000..b2c95f7 --- /dev/null +++ b/extensions/paho-mqtt5/runtime/pom.xml @@ -0,0 +1,113 @@ +<?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-paho-mqtt5-parent</artifactId> + <version>1.8.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-paho-mqtt5</artifactId> + <name>Camel Quarkus :: Paho MQTT5 :: Runtime</name> + <description>Communicate with MQTT message brokers using Eclipse Paho MQTT v5 Client.</description> + + <properties> + <camel.quarkus.jvmSince>1.8.0</camel.quarkus.jvmSince> + <camel.quarkus.nativeSince>1.8.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>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-paho-mqtt5</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/paho-mqtt5/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/paho-mqtt5/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000..67ac7e2 --- /dev/null +++ b/extensions/paho-mqtt5/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 Paho MQTT5" +description: "Communicate with MQTT message brokers using Eclipse Paho MQTT v5 Client" +metadata: + guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/paho-mqtt5.html" + categories: + - "integration" + status: + - "stable" diff --git a/extensions/pom.xml b/extensions/pom.xml index 69112b8..6d50929 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -189,6 +189,7 @@ <module>opentracing</module> <module>optaplanner</module> <module>paho</module> + <module>paho-mqtt5</module> <module>pdf</module> <module>pg-replication-slot</module> <module>pgevent</module> diff --git a/integration-tests/paho-mqtt5/pom.xml b/integration-tests/paho-mqtt5/pom.xml new file mode 100644 index 0000000..f85575a --- /dev/null +++ b/integration-tests/paho-mqtt5/pom.xml @@ -0,0 +1,120 @@ +<?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.8.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-integration-test-paho-mqtt5</artifactId> + <name>Camel Quarkus :: Integration Tests :: Paho MQTT 5</name> + <description>Integration tests for Camel Quarkus Paho MQTT 5 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-paho-mqtt5</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> + + <!-- 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-paho-mqtt5-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/paho-mqtt5/src/main/java/org/apache/camel/quarkus/component/paho/mqtt5/it/PahoMqtt5Resource.java b/integration-tests/paho-mqtt5/src/main/java/org/apache/camel/quarkus/component/paho/mqtt5/it/PahoMqtt5Resource.java new file mode 100644 index 0000000..14eda05 --- /dev/null +++ b/integration-tests/paho-mqtt5/src/main/java/org/apache/camel/quarkus/component/paho/mqtt5/it/PahoMqtt5Resource.java @@ -0,0 +1,71 @@ +/* + * 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.paho.mqtt5.it; + +import java.net.URI; + +import javax.enterprise.context.ApplicationScoped; +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.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.apache.camel.ConsumerTemplate; +import org.apache.camel.ProducerTemplate; +import org.eclipse.microprofile.config.ConfigProvider; + +@Path("/paho-mqtt5") +@ApplicationScoped +public class PahoMqtt5Resource { + + @Inject + ProducerTemplate producerTemplate; + + @Inject + ConsumerTemplate consumerTemplate; + + @Path("/{protocol}/{queueName}") + @GET + @Produces(MediaType.TEXT_PLAIN) + public String consumePahoMessage( + @PathParam("protocol") String protocol, + @PathParam("queueName") String queueName) { + return consumerTemplate.receiveBody("paho-mqtt5:" + queueName + "?brokerUrl=" + brokerUrl(protocol), 5000, + String.class); + } + + @Path("/{protocol}/{queueName}") + @POST + @Consumes(MediaType.TEXT_PLAIN) + public Response producePahoMessage( + @PathParam("protocol") String protocol, + @PathParam("queueName") String queueName, + String message) throws Exception { + producerTemplate.sendBody("paho-mqtt5:" + queueName + "?retained=true&brokerUrl=" + brokerUrl(protocol), message); + return Response.created(new URI("https://camel.apache.org/")).build(); + } + + private String brokerUrl(String protocol) { + return ConfigProvider.getConfig().getValue("paho5.broker." + protocol + ".url", String.class); + } + +} diff --git a/integration-tests/paho-mqtt5/src/test/java/org/apache/camel/quarkus/component/paho/mqtt5/it/PahoMqtt5IT.java b/integration-tests/paho-mqtt5/src/test/java/org/apache/camel/quarkus/component/paho/mqtt5/it/PahoMqtt5IT.java new file mode 100644 index 0000000..5a8ce02 --- /dev/null +++ b/integration-tests/paho-mqtt5/src/test/java/org/apache/camel/quarkus/component/paho/mqtt5/it/PahoMqtt5IT.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.paho.mqtt5.it; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +class PahoMqtt5IT extends PahoMqtt5Test { + +} diff --git a/integration-tests/paho-mqtt5/src/test/java/org/apache/camel/quarkus/component/paho/mqtt5/it/PahoMqtt5Test.java b/integration-tests/paho-mqtt5/src/test/java/org/apache/camel/quarkus/component/paho/mqtt5/it/PahoMqtt5Test.java new file mode 100644 index 0000000..25ffaf2 --- /dev/null +++ b/integration-tests/paho-mqtt5/src/test/java/org/apache/camel/quarkus/component/paho/mqtt5/it/PahoMqtt5Test.java @@ -0,0 +1,52 @@ +/* + * 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.paho.mqtt5.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.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import static org.hamcrest.core.Is.is; + +@QuarkusTest +@QuarkusTestResource(PahoMqtt5TestResource.class) +class PahoMqtt5Test { + + @ParameterizedTest + @ValueSource(strings = { "tcp", "ws" }) + public void sendReceive(String protocol) { + String message = "Hello Camel Quarkus " + protocol; + + RestAssured.given() + .contentType(ContentType.TEXT) + .body(message) + .post("/paho-mqtt5/tcp/{queueName}", protocol + "-test-queue") + .then() + .statusCode(201); + + RestAssured.given() + .contentType(ContentType.TEXT) + .get("/paho-mqtt5/tcp/{queueName}", protocol + "-test-queue") + .then() + .statusCode(200) + .body(is(message)); + } + +} diff --git a/integration-tests/paho-mqtt5/src/test/java/org/apache/camel/quarkus/component/paho/mqtt5/it/PahoMqtt5TestResource.java b/integration-tests/paho-mqtt5/src/test/java/org/apache/camel/quarkus/component/paho/mqtt5/it/PahoMqtt5TestResource.java new file mode 100644 index 0000000..6f8298b --- /dev/null +++ b/integration-tests/paho-mqtt5/src/test/java/org/apache/camel/quarkus/component/paho/mqtt5/it/PahoMqtt5TestResource.java @@ -0,0 +1,69 @@ +/* + * 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.paho.mqtt5.it; + +import java.util.Map; + +import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; +import org.apache.camel.util.CollectionHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.output.Slf4jLogConsumer; +import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.utility.TestcontainersConfiguration; + +public class PahoMqtt5TestResource implements QuarkusTestResourceLifecycleManager { + + private static final Logger LOGGER = LoggerFactory.getLogger(PahoMqtt5TestResource.class); + private static final String IMAGE = "eclipse-mosquitto:1.6.12"; + private static final int TCP_PORT = 1883; + + private GenericContainer<?> container; + + @Override + public Map<String, String> start() { + LOGGER.info(TestcontainersConfiguration.getInstance().toString()); + + try { + container = new GenericContainer<>(IMAGE) + .withExposedPorts(TCP_PORT) + .withLogConsumer(new Slf4jLogConsumer(LOGGER)) + .waitingFor(Wait.forLogMessage(".* mosquitto version .* running", 1)) + .waitingFor(Wait.forListeningPort()); + + container.start(); + + return CollectionHelper.mapOf( + "paho5.broker.tcp.url", String.format("tcp://localhost:%d", container.getMappedPort(TCP_PORT))); + + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public void stop() { + try { + if (container != null) { + container.stop(); + } + } catch (Exception e) { + // ignored + } + } +} diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index b15582b..39fe196 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -159,6 +159,7 @@ <module>openapi-java</module> <module>opentracing</module> <module>optaplanner</module> + <module>paho-mqtt5</module> <module>pdf</module> <module>pg-replication-slot</module> <module>pgevent</module> diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index 523a07c..9b6588b 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -1661,6 +1661,11 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> + <artifactId>camel-paho-mqtt5</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> <artifactId>camel-pdf</artifactId> <version>${camel.version}</version> </dependency> @@ -4431,6 +4436,16 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-paho-mqtt5</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-paho-mqtt5-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-pdf</artifactId> <version>${camel-quarkus.version}</version> </dependency> diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml index 23b86eb..92853d0 100644 --- a/tooling/scripts/test-categories.yaml +++ b/tooling/scripts/test-categories.yaml @@ -173,6 +173,7 @@ platform: - rest-openapi - csimple - aws2-grouped + - paho-mqtt5 saas: - box - github