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 a17e808 Add extension for smallrye-reactive-messaging-camel a17e808 is described below commit a17e80846974534bfa7a1308a9f5dc14a5bd7936 Author: James Netherton <jamesnether...@gmail.com> AuthorDate: Wed Aug 5 13:25:05 2020 +0100 Add extension for smallrye-reactive-messaging-camel Fixes #1469 --- .../extensions/smallrye-reactive-messaging.adoc | 38 ++++++ .../pages/list-of-camel-quarkus-extensions.adoc | 4 +- extensions/pom.xml | 1 + .../smallrye-reactive-messaging/deployment/pom.xml | 69 +++++++++++ .../SmallRyeReactiveMessagingProcessor.java | 87 +++++++++++++ extensions/smallrye-reactive-messaging/pom.xml | 37 ++++++ .../smallrye-reactive-messaging/runtime/pom.xml | 100 +++++++++++++++ .../runtime/src/main/doc/configuration.adoc | 4 + .../runtime/src/main/doc/usage.adoc | 4 + .../main/resources/META-INF/quarkus-extension.yaml | 31 +++++ integration-tests/pom.xml | 1 + .../smallrye-reactive-messaging/pom.xml | 137 +++++++++++++++++++++ .../reactive/messaging/it/PublisherRoute.java | 62 ++++++++++ .../reactive/messaging/it/ResultsBean.java | 36 ++++++ .../it/SmallRyeReactiveMessagingResource.java | 57 +++++++++ .../reactive/messaging/it/SubscriberRoute.java | 48 ++++++++ .../messaging/it/SmallRyeReactiveMessagingIT.java | 24 ++++ .../it/SmallRyeReactiveMessagingTest.java | 72 +++++++++++ pom.xml | 1 + poms/bom/pom.xml | 15 +++ tooling/scripts/test-categories.yaml | 1 + 21 files changed, 828 insertions(+), 1 deletion(-) diff --git a/docs/modules/ROOT/pages/extensions/smallrye-reactive-messaging.adoc b/docs/modules/ROOT/pages/extensions/smallrye-reactive-messaging.adoc new file mode 100644 index 0000000..b3b554d --- /dev/null +++ b/docs/modules/ROOT/pages/extensions/smallrye-reactive-messaging.adoc @@ -0,0 +1,38 @@ +// Do not edit directly! +// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page + +[[smallrye-reactive-messaging]] += SmallRye Reactive Messaging + +[.badges] +[.badge-key]##Since Camel Quarkus##[.badge-version]##1.0.0-CR4## [.badge-key]##JVM##[.badge-supported]##supported## [.badge-key]##Native##[.badge-supported]##supported## + +Camel integration with SmallRye Reactive Messaging + +== Maven coordinates + +[source,xml] +---- +<dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-smallrye-reactive-messaging</artifactId> +</dependency> +---- + +Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications. + +== Usage + +This extension leverages https://smallrye.io/smallrye-reactive-messaging/smallrye-reactive-messaging/2.2/camel/camel.html[SmallRye Reactive Messaging]. +Examples for how to use the Camel connector are outlined within the https://smallrye.io/smallrye-reactive-messaging/smallrye-reactive-messaging/2.2/camel/camel.html[documentation]. +Note that where the documentation makes references to Camel component maven dependencies, you should ensure that the corresponding camel-quarkus extension is used. +E.g `<artifactId>camel-file</artifactId>` should be `<artifactId>camel-quarkus-file</artifactId>`. + + +== Additional Camel Quarkus configuration + +This extension leverages the Camel xref:extensions/reactive-streams.adoc[Reactive Streams] extension. Various aspects of the reactive streams component can be configured +via the configuration options outlined within the xref:extensions/reactive-streams.adoc[documentation]. + +This extension also leverages the Quarkus SmallRye Reactive Messaging extension. Its configuration options are documented https://quarkus.io/guides/all-config#quarkus-smallrye-reactive-messaging_quarkus-smallrye-reactive-messaging[here]. + diff --git a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc index 67b1359..f3a3e0f 100644 --- a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc +++ b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc @@ -443,7 +443,7 @@ Number of Camel languages: 13 in 7 JAR artifacts (0 deprecated) == Miscellaneous Extensions // others: START -Number of miscellaneous extensions: 17 in 17 JAR artifacts (1 deprecated) +Number of miscellaneous extensions: 18 in 18 JAR artifacts (1 deprecated) [width="100%",cols="4,1,1,1,5",options="header"] |=== @@ -479,6 +479,8 @@ Number of miscellaneous extensions: 17 in 17 JAR artifacts (1 deprecated) | xref:extensions/reactive-executor.adoc[Reactive Executor Vert.x] | camel-quarkus-reactive-executor | Native + Stable | 0.3.0 | Reactive Executor for camel-core using Vert.x +| xref:extensions/smallrye-reactive-messaging.adoc[SmallRye Reactive Messaging] | camel-quarkus-smallrye-reactive-messaging | Native + Stable | 1.0.0-CR4 | Camel integration with SmallRye Reactive Messaging + | xref:extensions/xml-io.adoc[XML IO] | camel-quarkus-xml-io | Native + Stable | 1.0.0-M5 | An XML stack for parsing XML route definitions. A fast an light weight alternative to camel-quarkus-xml-jaxp | xref:extensions/xml-jaxb.adoc[XML JAXB] | camel-quarkus-xml-jaxb | Native + Stable | 1.0.0-M5 | An XML stack for parsing XML route definitions. A legacy alternative to the fast an light weight camel-quarkus-xml-io diff --git a/extensions/pom.xml b/extensions/pom.xml index 8e10044..1879a80 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -156,6 +156,7 @@ <module>sjms</module> <module>sjms2</module> <module>slack</module> + <module>smallrye-reactive-messaging</module> <module>snakeyaml</module> <module>soap</module> <module>sql</module> diff --git a/extensions/smallrye-reactive-messaging/deployment/pom.xml b/extensions/smallrye-reactive-messaging/deployment/pom.xml new file mode 100644 index 0000000..08b0920 --- /dev/null +++ b/extensions/smallrye-reactive-messaging/deployment/pom.xml @@ -0,0 +1,69 @@ +<?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-smallrye-reactive-messaging-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-smallrye-reactive-messaging-deployment</artifactId> + <name>Camel Quarkus :: SmallRye Reactive Messaging :: Deployment</name> + + <dependencies> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-smallrye-reactive-messaging-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-reactive-streams-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-smallrye-reactive-messaging</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/smallrye-reactive-messaging/deployment/src/main/java/org/apache/camel/quarkus/component/smallrye/reactive/messaging/deployment/SmallRyeReactiveMessagingProcessor.java b/extensions/smallrye-reactive-messaging/deployment/src/main/java/org/apache/camel/quarkus/component/smallrye/reactive/messaging/deployment/SmallRyeReactiveMessagingProcessor.java new file mode 100644 index 0000000..b2bc03a --- /dev/null +++ b/extensions/smallrye-reactive-messaging/deployment/src/main/java/org/apache/camel/quarkus/component/smallrye/reactive/messaging/deployment/SmallRyeReactiveMessagingProcessor.java @@ -0,0 +1,87 @@ +/* + * 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.smallrye.reactive.messaging.deployment; + +import io.quarkus.arc.deployment.AnnotationsTransformerBuildItem; +import io.quarkus.arc.processor.DotNames; +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.smallrye.reactive.messaging.camel.CamelConnector; +import org.jboss.jandex.AnnotationInstance; +import org.jboss.jandex.AnnotationTarget; +import org.jboss.jandex.AnnotationValue; +import org.jboss.jandex.ClassInfo; +import org.jboss.jandex.DotName; +import org.jboss.jandex.FieldInfo; +import org.jboss.jandex.MethodInfo; + +class SmallRyeReactiveMessagingProcessor { + + private static final DotName CAMEL_CONNECTOR_DOTNAME = DotName.createSimple(CamelConnector.class.getName()); + + private static final String FEATURE = "camel-smallrye-reactive-messaging"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + @BuildStep + void overrideSmallRyeReactiveMessagingConfiguration(BuildProducer<AnnotationsTransformerBuildItem> transformers) { + // Veto setup & configuration logic that is already handled by the camel-quarkus-reactive-streams extension + transformers.produce(new AnnotationsTransformerBuildItem(context -> { + if (context.isField()) { + FieldInfo fieldInfo = context.getTarget().asField(); + ClassInfo classInfo = fieldInfo.declaringClass(); + + // Make CamelReactiveStreamsService injectable from producers configured in the reactive-streams extension + if (classInfo.name().equals(CAMEL_CONNECTOR_DOTNAME) && fieldInfo.name().equals("reactive")) { + AnnotationInstance injectAnnotation = getAnnotationInstance(DotNames.INJECT, fieldInfo); + context.transform().add(injectAnnotation).done(); + } + } + + if (context.isMethod()) { + MethodInfo methodInfo = context.getTarget().asMethod(); + ClassInfo classInfo = methodInfo.declaringClass(); + + if (classInfo.name().equals(CAMEL_CONNECTOR_DOTNAME)) { + // Disable CamelReactiveStreamsService producer since the reactive-streams extension handles this + if (methodInfo.name().equals("getCamelReactive")) { + AnnotationInstance producesAnnotation = getAnnotationInstance(DotNames.PRODUCES, methodInfo); + context.transform() + .remove(annotationInstance -> annotationInstance.target().equals(producesAnnotation.target())) + .done(); + } + + // Remove @PostConstruct from the init method as the configuration logic is handled by the reactive-streams extension + if (methodInfo.name().equals("init")) { + AnnotationInstance postConstructAnnotation = getAnnotationInstance(DotNames.POST_CONSTRUCT, methodInfo); + context.transform() + .remove(methodAnnotation -> methodAnnotation.target().equals(postConstructAnnotation.target())) + .done(); + } + } + } + })); + } + + private AnnotationInstance getAnnotationInstance(DotName dotName, AnnotationTarget target) { + return AnnotationInstance.create(dotName, target, new AnnotationValue[0]); + } +} diff --git a/extensions/smallrye-reactive-messaging/pom.xml b/extensions/smallrye-reactive-messaging/pom.xml new file mode 100644 index 0000000..bda310c --- /dev/null +++ b/extensions/smallrye-reactive-messaging/pom.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-build-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../../poms/build-parent/pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-smallrye-reactive-messaging-parent</artifactId> + <name>Camel Quarkus :: SmallRye Reactive Messaging</name> + <packaging>pom</packaging> + + <modules> + <module>deployment</module> + <module>runtime</module> + </modules> +</project> diff --git a/extensions/smallrye-reactive-messaging/runtime/pom.xml b/extensions/smallrye-reactive-messaging/runtime/pom.xml new file mode 100644 index 0000000..9ef2353 --- /dev/null +++ b/extensions/smallrye-reactive-messaging/runtime/pom.xml @@ -0,0 +1,100 @@ +<?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-smallrye-reactive-messaging-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-smallrye-reactive-messaging</artifactId> + <name>Camel Quarkus :: SmallRye Reactive Messaging :: Runtime</name> + <description>Camel integration with SmallRye Reactive Messaging</description> + + <properties> + <firstVersion>1.0.0-CR4</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-smallrye-reactive-messaging</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-reactive-streams</artifactId> + </dependency> + <dependency> + <groupId>io.smallrye.reactive</groupId> + <artifactId>smallrye-reactive-messaging-camel</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/smallrye-reactive-messaging/runtime/src/main/doc/configuration.adoc b/extensions/smallrye-reactive-messaging/runtime/src/main/doc/configuration.adoc new file mode 100644 index 0000000..837c5b3 --- /dev/null +++ b/extensions/smallrye-reactive-messaging/runtime/src/main/doc/configuration.adoc @@ -0,0 +1,4 @@ +This extension leverages the Camel xref:extensions/reactive-streams.adoc[Reactive Streams] extension. Various aspects of the reactive streams component can be configured +via the configuration options outlined within the xref:extensions/reactive-streams.adoc[documentation]. + +This extension also leverages the Quarkus SmallRye Reactive Messaging extension. Its configuration options are documented https://quarkus.io/guides/all-config#quarkus-smallrye-reactive-messaging_quarkus-smallrye-reactive-messaging[here]. diff --git a/extensions/smallrye-reactive-messaging/runtime/src/main/doc/usage.adoc b/extensions/smallrye-reactive-messaging/runtime/src/main/doc/usage.adoc new file mode 100644 index 0000000..e9270ca --- /dev/null +++ b/extensions/smallrye-reactive-messaging/runtime/src/main/doc/usage.adoc @@ -0,0 +1,4 @@ +This extension leverages https://smallrye.io/smallrye-reactive-messaging/smallrye-reactive-messaging/2.2/camel/camel.html[SmallRye Reactive Messaging]. +Examples for how to use the Camel connector are outlined within the https://smallrye.io/smallrye-reactive-messaging/smallrye-reactive-messaging/2.2/camel/camel.html[documentation]. +Note that where the documentation makes references to Camel component maven dependencies, you should ensure that the corresponding camel-quarkus extension is used. +E.g `<artifactId>camel-file</artifactId>` should be `<artifactId>camel-quarkus-file</artifactId>`. diff --git a/extensions/smallrye-reactive-messaging/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/smallrye-reactive-messaging/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000..d124a02 --- /dev/null +++ b/extensions/smallrye-reactive-messaging/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 SmallRye Reactive Messaging" +description: "Camel integration with SmallRye Reactive Messaging" +metadata: + guide: "https://camel.apache.org/camel-quarkus/latest/extensions/smallrye-reactive-messaging.html" + categories: + - "integration" + status: + - "stable" diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 85b7074..afcb1c3 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -138,6 +138,7 @@ <module>servicenow</module> <module>servlet</module> <module>slack</module> + <module>smallrye-reactive-messaging</module> <module>soap</module> <module>sql</module> <module>stream</module> diff --git a/integration-tests/smallrye-reactive-messaging/pom.xml b/integration-tests/smallrye-reactive-messaging/pom.xml new file mode 100644 index 0000000..97183d3 --- /dev/null +++ b/integration-tests/smallrye-reactive-messaging/pom.xml @@ -0,0 +1,137 @@ +<?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-smallrye-reactive-messaging</artifactId> + <name>Camel Quarkus :: Integration Tests :: SmallRye Reactive Messaging</name> + <description>Integration tests for Camel Quarkus SmallRye Reactive Messaging extension</description> + + <properties> + <!-- mvnd, a.k.a. Maven Daemon: https://github.com/gnodet/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 rule whenever you change the dependencies of this module by running --> + <!-- mvn process-resources -Pformat from the root directory --> + <mvnd.builder.rule>camel-quarkus-direct-deployment,camel-quarkus-file-deployment,camel-quarkus-support-policy-deployment,camel-quarkus-smallrye-reactive-messaging-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-direct</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-file</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-smallrye-reactive-messaging</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.awaitility</groupId> + <artifactId>awaitility</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/smallrye-reactive-messaging/src/main/java/org/apache/camel/quarkus/component/smallrye/reactive/messaging/it/PublisherRoute.java b/integration-tests/smallrye-reactive-messaging/src/main/java/org/apache/camel/quarkus/component/smallrye/reactive/messaging/it/PublisherRoute.java new file mode 100644 index 0000000..b32edae --- /dev/null +++ b/integration-tests/smallrye-reactive-messaging/src/main/java/org/apache/camel/quarkus/component/smallrye/reactive/messaging/it/PublisherRoute.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.smallrye.reactive.messaging.it; + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import javax.inject.Inject; + +import org.apache.camel.Exchange; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService; +import org.eclipse.microprofile.reactive.messaging.Incoming; +import org.eclipse.microprofile.reactive.messaging.Outgoing; +import org.reactivestreams.Publisher; + +public class PublisherRoute extends RouteBuilder { + + @Inject + CamelReactiveStreamsService camel; + + @Inject + ResultsBean results; + + @Incoming("sink") + public CompletionStage<Void> sink(String value) { + results.addResult(value); + return CompletableFuture.completedFuture(null); + } + + @Incoming("camel-route-pub") + @Outgoing("sink") + public String extract(Exchange exchange) { + return exchange.getMessage().getBody(String.class); + } + + @Outgoing("camel-route-pub") + public Publisher<Exchange> source() { + return camel.fromStream("my-stream"); + } + + @Override + public void configure() { + from("direct:in") + .process(exchange -> exchange.getMessage().setBody(exchange.getIn().getBody(String.class).toUpperCase())) + .to("reactive-streams:my-stream"); + } +} diff --git a/integration-tests/smallrye-reactive-messaging/src/main/java/org/apache/camel/quarkus/component/smallrye/reactive/messaging/it/ResultsBean.java b/integration-tests/smallrye-reactive-messaging/src/main/java/org/apache/camel/quarkus/component/smallrye/reactive/messaging/it/ResultsBean.java new file mode 100644 index 0000000..6a2b39b --- /dev/null +++ b/integration-tests/smallrye-reactive-messaging/src/main/java/org/apache/camel/quarkus/component/smallrye/reactive/messaging/it/ResultsBean.java @@ -0,0 +1,36 @@ +/* + * 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.smallrye.reactive.messaging.it; + +import java.util.ArrayList; +import java.util.List; + +import javax.inject.Singleton; + +@Singleton +public class ResultsBean { + + private final List<String> results = new ArrayList<>(); + + public void addResult(String result) { + results.add(result); + } + + public List<String> getResults() { + return results; + } +} diff --git a/integration-tests/smallrye-reactive-messaging/src/main/java/org/apache/camel/quarkus/component/smallrye/reactive/messaging/it/SmallRyeReactiveMessagingResource.java b/integration-tests/smallrye-reactive-messaging/src/main/java/org/apache/camel/quarkus/component/smallrye/reactive/messaging/it/SmallRyeReactiveMessagingResource.java new file mode 100644 index 0000000..4a03fec --- /dev/null +++ b/integration-tests/smallrye-reactive-messaging/src/main/java/org/apache/camel/quarkus/component/smallrye/reactive/messaging/it/SmallRyeReactiveMessagingResource.java @@ -0,0 +1,57 @@ +/* + * 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.smallrye.reactive.messaging.it; + +import java.net.URI; + +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 org.apache.camel.ProducerTemplate; + +@Path("/smallrye-reactive-messaging") +public class SmallRyeReactiveMessagingResource { + + @Inject + ProducerTemplate producerTemplate; + + @Inject + ResultsBean results; + + @Path("/post") + @Consumes(MediaType.TEXT_PLAIN) + @POST + public Response post(String message) throws Exception { + producerTemplate.asyncSendBody("direct:in", message); + return Response + .created(new URI("https://camel.apache.org/")) + .build(); + } + + @Path("/values") + @Produces(MediaType.TEXT_PLAIN) + @GET + public String getValues() { + return String.join(",", results.getResults()); + } +} diff --git a/integration-tests/smallrye-reactive-messaging/src/main/java/org/apache/camel/quarkus/component/smallrye/reactive/messaging/it/SubscriberRoute.java b/integration-tests/smallrye-reactive-messaging/src/main/java/org/apache/camel/quarkus/component/smallrye/reactive/messaging/it/SubscriberRoute.java new file mode 100644 index 0000000..551860e --- /dev/null +++ b/integration-tests/smallrye-reactive-messaging/src/main/java/org/apache/camel/quarkus/component/smallrye/reactive/messaging/it/SubscriberRoute.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.smallrye.reactive.messaging.it; + +import javax.inject.Inject; + +import io.smallrye.mutiny.Multi; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService; +import org.eclipse.microprofile.reactive.messaging.Incoming; +import org.eclipse.microprofile.reactive.messaging.Outgoing; +import org.reactivestreams.Subscriber; + +public class SubscriberRoute extends RouteBuilder { + + @Inject + CamelReactiveStreamsService reactive; + + @Incoming("camel-route-sub") + public Subscriber<String> sink() { + return reactive.streamSubscriber("camel-sub", String.class); + } + + @Outgoing("camel-route-sub") + public Multi<String> source() { + return Multi.createFrom().items("a", "b", "c", "d"); + } + + @Override + public void configure() { + from("reactive-streams:camel-sub") + .to("file:./target?fileName=values.txt&fileExist=append"); + } +} diff --git a/integration-tests/smallrye-reactive-messaging/src/test/java/org/apache/camel/quarkus/component/smallrye/reactive/messaging/it/SmallRyeReactiveMessagingIT.java b/integration-tests/smallrye-reactive-messaging/src/test/java/org/apache/camel/quarkus/component/smallrye/reactive/messaging/it/SmallRyeReactiveMessagingIT.java new file mode 100644 index 0000000..bc82b41 --- /dev/null +++ b/integration-tests/smallrye-reactive-messaging/src/test/java/org/apache/camel/quarkus/component/smallrye/reactive/messaging/it/SmallRyeReactiveMessagingIT.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.smallrye.reactive.messaging.it; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +class SmallRyeReactiveMessagingIT extends SmallRyeReactiveMessagingTest { + +} diff --git a/integration-tests/smallrye-reactive-messaging/src/test/java/org/apache/camel/quarkus/component/smallrye/reactive/messaging/it/SmallRyeReactiveMessagingTest.java b/integration-tests/smallrye-reactive-messaging/src/test/java/org/apache/camel/quarkus/component/smallrye/reactive/messaging/it/SmallRyeReactiveMessagingTest.java new file mode 100644 index 0000000..005910e --- /dev/null +++ b/integration-tests/smallrye-reactive-messaging/src/test/java/org/apache/camel/quarkus/component/smallrye/reactive/messaging/it/SmallRyeReactiveMessagingTest.java @@ -0,0 +1,72 @@ +/* + * 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.smallrye.reactive.messaging.it; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import org.junit.jupiter.api.Test; + +import static org.awaitility.Awaitility.await; + +@QuarkusTest +class SmallRyeReactiveMessagingTest { + + @Test + public void testSmallRyeReactiveMessagingCamelRouteSubscriber() { + Path path = Paths.get("target/values.txt"); + try { + await().atMost(10, TimeUnit.SECONDS).until(() -> { + if (!path.toFile().isFile()) { + return false; + } + List<String> list = Files.readAllLines(path); + return list.size() == 1 && list.get(0).equalsIgnoreCase("abcd"); + }); + } finally { + path.toFile().delete(); + } + } + + @Test + public void testSmallRyeReactiveMessagingCamelRoutePublisher() { + Stream.of("a", "b", "c", "d") + .forEach(body -> { + RestAssured.given() + .body(body) + .post("/smallrye-reactive-messaging/post") + .then() + .statusCode(201); + }); + + await().atMost(10, TimeUnit.SECONDS).until(() -> { + String response = RestAssured.get("/smallrye-reactive-messaging/values") + .then() + .statusCode(200) + .extract() + .body() + .asString(); + return response.equals("A,B,C,D"); + }); + } +} diff --git a/pom.xml b/pom.xml index 8639037..3634157 100644 --- a/pom.xml +++ b/pom.xml @@ -70,6 +70,7 @@ <quarkus-qpid-jms.version>0.17.0</quarkus-qpid-jms.version> <protobuf.version>3.11.1</protobuf.version> <retrofit.version>2.5.0</retrofit.version> + <smallrye.reactive.messaging.camel.version>2.2.1</smallrye.reactive.messaging.camel.version> <!-- Keep spring.version aligned with the version used by Camel --> <spring.version>5.2.7.RELEASE</spring.version> <snakeyaml.version>1.26</snakeyaml.version> diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index 4d33264..b3dcdb2 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -2666,6 +2666,16 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-smallrye-reactive-messaging</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-smallrye-reactive-messaging-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-snakeyaml</artifactId> <version>${camel-quarkus.version}</version> </dependency> @@ -3220,6 +3230,11 @@ <version>${debezium.version}</version> </dependency> <dependency> + <groupId>io.smallrye.reactive</groupId> + <artifactId>smallrye-reactive-messaging-camel</artifactId> + <version>${smallrye.reactive.messaging.camel.version}</version> + </dependency> + <dependency> <groupId>javax.xml.ws</groupId> <artifactId>jaxws-api</artifactId> <version>${java.xml.ws.version}</version> diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml index ceb568a..2790afe 100644 --- a/tooling/scripts/test-categories.yaml +++ b/tooling/scripts/test-categories.yaml @@ -110,6 +110,7 @@ platform: - reactive-streams - rest - rest-openapi + - smallrye-reactive-messaging saas: - box - github