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
The following commit(s) were added to refs/heads/master by this push: new 5e311a5 Add vertx-websocket component extension 5e311a5 is described below commit 5e311a50fb8f34bfefd23eb30b4383805acd9ef0 Author: James Netherton <jamesnether...@gmail.com> AuthorDate: Thu Sep 3 13:27:05 2020 +0100 Add vertx-websocket component extension Fixes #1301 --- catalog/pom.xml | 1 + docs/modules/ROOT/nav.adoc | 1 + docs/modules/ROOT/pages/reference/components.adoc | 3 + .../reference/extensions/vertx-websocket.adoc | 29 +++++ docs/modules/ROOT/pages/reference/index.adoc | 3 + extensions/pom.xml | 1 + extensions/vertx-websocket/deployment/pom.xml | 67 +++++++++++ .../deployment/VertxWebsocketProcessor.java | 45 ++++++++ extensions/vertx-websocket/pom.xml | 39 +++++++ extensions/vertx-websocket/runtime/pom.xml | 98 +++++++++++++++++ .../vertx/websocket/VertxWebsocketRecorder.java | 75 +++++++++++++ .../main/resources/META-INF/quarkus-extension.yaml | 31 ++++++ integration-tests/pom.xml | 1 + integration-tests/vertx-websocket/pom.xml | 122 +++++++++++++++++++++ .../vertx/websocket/it/VertxWebsocketRoutes.java | 29 +++++ .../vertx/websocket/it/VertxWebsocketIT.java | 24 ++++ .../vertx/websocket/it/VertxWebsocketTest.java | 62 +++++++++++ poms/bom/pom.xml | 15 +++ tooling/scripts/test-categories.yaml | 1 + 19 files changed, 647 insertions(+) diff --git a/catalog/pom.xml b/catalog/pom.xml index 8742954..4e7ad51 100644 --- a/catalog/pom.xml +++ b/catalog/pom.xml @@ -277,6 +277,7 @@ camel-quarkus-velocity camel-quarkus-vertx camel-quarkus-vertx-http + camel-quarkus-vertx-websocket camel-quarkus-vm camel-quarkus-weather camel-quarkus-web3j diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index 1f2965f..d2ba977 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -229,6 +229,7 @@ *** xref:reference/extensions/velocity.adoc[Velocity] *** xref:reference/extensions/vertx.adoc[Vert.x] *** xref:reference/extensions/vertx-http.adoc[Vert.x HTTP Client] +*** xref:reference/extensions/vertx-websocket.adoc[Vert.x WebSocket] *** xref:reference/extensions/vm.adoc[VM] *** xref:reference/extensions/weather.adoc[Weather] *** xref:reference/extensions/web3j.adoc[Web3j Ethereum Blockchain] diff --git a/docs/modules/ROOT/pages/reference/components.adoc b/docs/modules/ROOT/pages/reference/components.adoc index c7f3157..5174302 100644 --- a/docs/modules/ROOT/pages/reference/components.adoc +++ b/docs/modules/ROOT/pages/reference/components.adoc @@ -724,6 +724,9 @@ Stable | 1.0.0 | Send and receive messages to/from Vert.x Event Bus. | xref:reference/extensions/vertx-http.adoc[Vert.x HTTP Client] | [.camel-element-artifact]##camel-quarkus-vertx-http## | [.camel-element-Native]##Native## + Stable | 1.1.0 | Camel HTTP client support with Vert.x +| xref:reference/extensions/vertx-websocket.adoc[Vert.x WebSocket] | [.camel-element-artifact]##camel-quarkus-vertx-websocket## | [.camel-element-Native]##Native## + +Stable | 1.1.0 | Camel WebSocket support with Vert.x + | xref:reference/extensions/vm.adoc[VM] | [.camel-element-artifact]##camel-quarkus-vm## | [.camel-element-Native]##Native## + Stable | 0.3.0 | Call another endpoint in the same CamelContext asynchronously. diff --git a/docs/modules/ROOT/pages/reference/extensions/vertx-websocket.adoc b/docs/modules/ROOT/pages/reference/extensions/vertx-websocket.adoc new file mode 100644 index 0000000..7375201 --- /dev/null +++ b/docs/modules/ROOT/pages/reference/extensions/vertx-websocket.adoc @@ -0,0 +1,29 @@ +// Do not edit directly! +// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page + +[[vertx-websocket]] += Vert.x WebSocket +:page-aliases: extensions/vertx-websocket.adoc + +[.badges] +[.badge-key]##Since Camel Quarkus##[.badge-version]##1.1.0## [.badge-key]##JVM##[.badge-supported]##supported## [.badge-key]##Native##[.badge-supported]##supported## + +Camel WebSocket support with Vert.x + +== What's inside + +* https://camel.apache.org/components/latest/vertx-websocket-component.html[Vert.x WebSocket component], URI syntax: `vertx-websocket:host:port/path` + +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-websocket</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/pages/reference/index.adoc b/docs/modules/ROOT/pages/reference/index.adoc index 8308c71..48dc185 100644 --- a/docs/modules/ROOT/pages/reference/index.adoc +++ b/docs/modules/ROOT/pages/reference/index.adoc @@ -665,6 +665,9 @@ Stable | 1.0.0 | Send and receive messages to/from Vert.x Event Bus. | xref:reference/extensions/vertx-http.adoc[Vert.x HTTP Client] | camel-quarkus-vertx-http | [.camel-element-Native]##Native## + Stable | 1.1.0 | Camel HTTP client support with Vert.x +| xref:reference/extensions/vertx-websocket.adoc[Vert.x WebSocket] | camel-quarkus-vertx-websocket | [.camel-element-Native]##Native## + +Stable | 1.1.0 | Camel WebSocket support with Vert.x + | xref:reference/extensions/vm.adoc[VM] | camel-quarkus-vm | [.camel-element-Native]##Native## + Stable | 0.3.0 | Call another endpoint in the same CamelContext asynchronously. diff --git a/extensions/pom.xml b/extensions/pom.xml index 4b35bd5..db5b167 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -176,6 +176,7 @@ <module>validator</module> <module>vertx</module> <module>vertx-http</module> + <module>vertx-websocket</module> <module>vm</module> <module>websocket-jsr356</module> <module>xpath</module> diff --git a/extensions/vertx-websocket/deployment/pom.xml b/extensions/vertx-websocket/deployment/pom.xml new file mode 100644 index 0000000..dab3c0e --- /dev/null +++ b/extensions/vertx-websocket/deployment/pom.xml @@ -0,0 +1,67 @@ +<?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-websocket-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-vertx-websocket-deployment</artifactId> + <name>Camel Quarkus :: Vert.x WebSocket :: Deployment</name> + + <dependencies> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-vertx-web-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-websocket</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-websocket/deployment/src/main/java/org/apache/camel/quarkus/component/vertx/websocket/deployment/VertxWebsocketProcessor.java b/extensions/vertx-websocket/deployment/src/main/java/org/apache/camel/quarkus/component/vertx/websocket/deployment/VertxWebsocketProcessor.java new file mode 100644 index 0000000..7271b98 --- /dev/null +++ b/extensions/vertx-websocket/deployment/src/main/java/org/apache/camel/quarkus/component/vertx/websocket/deployment/VertxWebsocketProcessor.java @@ -0,0 +1,45 @@ +/* + * 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.websocket.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 io.quarkus.vertx.http.deployment.VertxWebRouterBuildItem; +import org.apache.camel.component.vertx.websocket.VertxWebsocketComponent; +import org.apache.camel.quarkus.component.vertx.websocket.VertxWebsocketRecorder; +import org.apache.camel.quarkus.core.deployment.spi.CamelRuntimeBeanBuildItem; + +class VertxWebsocketProcessor { + + private static final String FEATURE = "camel-vertx-websocket"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + @BuildStep + @Record(ExecutionTime.RUNTIME_INIT) + CamelRuntimeBeanBuildItem configureVertxWebsocketComponent(VertxBuildItem vertx, VertxWebRouterBuildItem router, + VertxWebsocketRecorder recorder) { + return new CamelRuntimeBeanBuildItem("vertx-websocket", VertxWebsocketComponent.class.getName(), + recorder.createVertxWebsocketComponent(vertx.getVertx(), router.getRouter())); + } +} diff --git a/extensions/vertx-websocket/pom.xml b/extensions/vertx-websocket/pom.xml new file mode 100644 index 0000000..44c558a --- /dev/null +++ b/extensions/vertx-websocket/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.1.0-SNAPSHOT</version> + <relativePath>../../poms/build-parent/pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-vertx-websocket-parent</artifactId> + <name>Camel Quarkus :: Vert.x WebSocket</name> + <packaging>pom</packaging> + + <modules> + <module>deployment</module> + <module>runtime</module> + </modules> +</project> diff --git a/extensions/vertx-websocket/runtime/pom.xml b/extensions/vertx-websocket/runtime/pom.xml new file mode 100644 index 0000000..26912a5 --- /dev/null +++ b/extensions/vertx-websocket/runtime/pom.xml @@ -0,0 +1,98 @@ +<?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-websocket-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-vertx-websocket</artifactId> + <name>Camel Quarkus :: Vert.x WebSocket :: Runtime</name> + <description>Camel WebSocket support with Vert.x</description> + + <properties> + <firstVersion>1.1.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-vertx-web</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-vertx-websocket</artifactId> + </dependency> + </dependencies> + + <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> + <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/vertx-websocket/runtime/src/main/java/org/apache/camel/quarkus/component/vertx/websocket/VertxWebsocketRecorder.java b/extensions/vertx-websocket/runtime/src/main/java/org/apache/camel/quarkus/component/vertx/websocket/VertxWebsocketRecorder.java new file mode 100644 index 0000000..fc40cc3 --- /dev/null +++ b/extensions/vertx-websocket/runtime/src/main/java/org/apache/camel/quarkus/component/vertx/websocket/VertxWebsocketRecorder.java @@ -0,0 +1,75 @@ +/* + * 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.websocket; + +import java.util.Map; +import java.util.concurrent.ExecutionException; + +import io.quarkus.runtime.RuntimeValue; +import io.quarkus.runtime.annotations.Recorder; +import io.vertx.core.Vertx; +import io.vertx.ext.web.Router; +import org.apache.camel.Endpoint; +import org.apache.camel.component.vertx.websocket.VertxWebsocketComponent; +import org.apache.camel.component.vertx.websocket.VertxWebsocketEndpoint; +import org.apache.camel.component.vertx.websocket.VertxWebsocketHost; +import org.apache.camel.component.vertx.websocket.VertxWebsocketHostConfiguration; +import org.apache.camel.component.vertx.websocket.VertxWebsocketHostKey; + +@Recorder +public class VertxWebsocketRecorder { + + public RuntimeValue<VertxWebsocketComponent> createVertxWebsocketComponent(RuntimeValue<Vertx> vertx, + RuntimeValue<Router> router) { + QuarkusVertxWebsocketComponent component = new QuarkusVertxWebsocketComponent(router.getValue()); + component.setVertx(vertx.getValue()); + return new RuntimeValue<>(component); + } + + static final class QuarkusVertxWebsocketComponent extends VertxWebsocketComponent { + private final Router router; + + public QuarkusVertxWebsocketComponent(Router router) { + this.router = router; + } + + @Override + protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { + VertxWebsocketEndpoint endpoint = (VertxWebsocketEndpoint) super.createEndpoint(uri, remaining, parameters); + endpoint.getConfiguration().setRouter(router); + return endpoint; + } + + @Override + protected VertxWebsocketHost createVertxWebsocketHost(VertxWebsocketHostConfiguration hostConfiguration, + VertxWebsocketHostKey hostKey) { + return new QuarkusVertxWebsocketHost(hostConfiguration, hostKey); + } + } + + static final class QuarkusVertxWebsocketHost extends VertxWebsocketHost { + public QuarkusVertxWebsocketHost(VertxWebsocketHostConfiguration websocketHostConfiguration, + VertxWebsocketHostKey key) { + super(websocketHostConfiguration, key); + } + + @Override + public void start() throws InterruptedException, ExecutionException { + // Noop as quarkus-vertx-web handles the server lifecycle + } + } +} diff --git a/extensions/vertx-websocket/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/vertx-websocket/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000..e47ef1e --- /dev/null +++ b/extensions/vertx-websocket/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 WebSocket" +description: "Camel WebSocket support with Vert.x" +metadata: + guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/vertx-websocket.html" + categories: + - "integration" + status: + - "stable" diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 405ede2..fa41cd9 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -149,6 +149,7 @@ <module>twitter</module> <module>validator</module> <module>vertx</module> + <module>vertx-websocket</module> <module>websocket-jsr356</module> <module>xml</module> <module>xstream</module> diff --git a/integration-tests/vertx-websocket/pom.xml b/integration-tests/vertx-websocket/pom.xml new file mode 100644 index 0000000..cab36b5 --- /dev/null +++ b/integration-tests/vertx-websocket/pom.xml @@ -0,0 +1,122 @@ +<?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.1.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-integration-test-vertx-websocket</artifactId> + <name>Camel Quarkus :: Integration Tests :: Vert.x WebSocket</name> + <description>Integration tests for Camel Quarkus Vert.x WebSocket extension</description> + + <properties> + <!-- mvnd, a.k.a. Maven Daemon: https://github.com/mvndaemon/mvnd --> + <!-- The following rule tells mvnd to build the listed deployment modules before this module. --> + <!-- This is important because mvnd builds modules in parallel by default. The deployment modules are not --> + <!-- explicit dependencies of this module in the Maven sense, although they are required by the Quarkus Maven plugin. --> + <!-- Please update the rule whenever you change the dependencies of this module by running --> + <!-- mvn process-resources -Pformat from the root directory --> + <mvnd.builder.rule>camel-quarkus-vertx-websocket-deployment</mvnd.builder.rule> + </properties> + + <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-vertx-websocket</artifactId> + </dependency> + + <!-- test dependencies --> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-undertow-websockets</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-junit5</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-maven-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>build</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <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-websocket/src/main/java/org/apache/camel/quarkus/component/vertx/websocket/it/VertxWebsocketRoutes.java b/integration-tests/vertx-websocket/src/main/java/org/apache/camel/quarkus/component/vertx/websocket/it/VertxWebsocketRoutes.java new file mode 100644 index 0000000..74b5a98 --- /dev/null +++ b/integration-tests/vertx-websocket/src/main/java/org/apache/camel/quarkus/component/vertx/websocket/it/VertxWebsocketRoutes.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.vertx.websocket.it; + +import org.apache.camel.builder.RouteBuilder; + +public class VertxWebsocketRoutes extends RouteBuilder { + + @Override + public void configure() throws Exception { + from("vertx-websocket://greeting") + .setBody(simple("Hello ${body}")) + .to("vertx-websocket://greeting"); + } +} diff --git a/integration-tests/vertx-websocket/src/test/java/org/apache/camel/quarkus/component/vertx/websocket/it/VertxWebsocketIT.java b/integration-tests/vertx-websocket/src/test/java/org/apache/camel/quarkus/component/vertx/websocket/it/VertxWebsocketIT.java new file mode 100644 index 0000000..2b3818e --- /dev/null +++ b/integration-tests/vertx-websocket/src/test/java/org/apache/camel/quarkus/component/vertx/websocket/it/VertxWebsocketIT.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.websocket.it; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +class VertxWebsocketIT extends VertxWebsocketTest { + +} diff --git a/integration-tests/vertx-websocket/src/test/java/org/apache/camel/quarkus/component/vertx/websocket/it/VertxWebsocketTest.java b/integration-tests/vertx-websocket/src/test/java/org/apache/camel/quarkus/component/vertx/websocket/it/VertxWebsocketTest.java new file mode 100644 index 0000000..2c8d316 --- /dev/null +++ b/integration-tests/vertx-websocket/src/test/java/org/apache/camel/quarkus/component/vertx/websocket/it/VertxWebsocketTest.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.vertx.websocket.it; + +import java.net.URI; +import java.util.concurrent.LinkedBlockingDeque; +import java.util.concurrent.TimeUnit; + +import javax.websocket.ClientEndpointConfig; +import javax.websocket.ContainerProvider; +import javax.websocket.Endpoint; +import javax.websocket.EndpointConfig; +import javax.websocket.MessageHandler; +import javax.websocket.Session; + +import io.quarkus.test.common.http.TestHTTPResource; +import io.quarkus.test.junit.QuarkusTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +@QuarkusTest +class VertxWebsocketTest { + + @TestHTTPResource("/greeting") + URI uri; + + @Test + public void testWebsocketChat() throws Exception { + LinkedBlockingDeque<String> message = new LinkedBlockingDeque<>(); + Endpoint endpoint = new Endpoint() { + @Override + public void onOpen(Session session, EndpointConfig endpointConfig) { + session.addMessageHandler(new MessageHandler.Whole<String>() { + @Override + public void onMessage(String s) { + message.add(s); + } + }); + session.getAsyncRemote().sendText("Camel Quarkus Vert.x WebSocket"); + } + }; + + ClientEndpointConfig config = ClientEndpointConfig.Builder.create().build(); + try (Session session = ContainerProvider.getWebSocketContainer().connectToServer(endpoint, config, uri)) { + Assertions.assertEquals("Hello Camel Quarkus Vert.x WebSocket", message.poll(5, TimeUnit.SECONDS)); + } + } +} diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index 4d024bf..94773ef 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -1513,6 +1513,11 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> + <artifactId>camel-vertx-websocket</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> <artifactId>camel-vm</artifactId> <version>${camel.version}</version> </dependency> @@ -3985,6 +3990,16 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-vertx-websocket</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-vertx-websocket-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-vm</artifactId> <version>${camel-quarkus.version}</version> </dependency> diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml index 05cfdcf..0665ab8 100644 --- a/tooling/scripts/test-categories.yaml +++ b/tooling/scripts/test-categories.yaml @@ -88,6 +88,7 @@ messaging-networking1: - ftp - http - graphql + - vertx-websocket misc: - braintree - jolt