You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2020/10/02 09:32:29 UTC

[camel-quarkus] branch master updated: Upgrade SmallRye Reactive Messaging Camel to 2.4.0

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 246c06f  Upgrade SmallRye Reactive Messaging Camel to 2.4.0
246c06f is described below

commit 246c06f6ca429b5dadb6da4c124ce84c1804edff
Author: James Netherton <ja...@gmail.com>
AuthorDate: Wed Sep 30 08:04:56 2020 +0100

    Upgrade SmallRye Reactive Messaging Camel to 2.4.0
    
    Fixes #1851
---
 .../SmallRyeReactiveMessagingProcessor.java        |  9 ----
 .../messaging/it/FilesMessageConsumer.java         | 56 ++++++++++++++++++++++
 .../it/SmallRyeReactiveMessagingResource.java      | 11 +++++
 .../src/main/resources/application.properties      | 18 +++++++
 .../it/SmallRyeReactiveMessagingTest.java          | 18 +++++++
 pom.xml                                            |  2 +-
 6 files changed, 104 insertions(+), 10 deletions(-)

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
index b2bc03a..675646f 100644
--- 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
@@ -33,7 +33,6 @@ 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
@@ -68,14 +67,6 @@ class SmallRyeReactiveMessagingProcessor {
                                 .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();
-                    }
                 }
             }
         }));
diff --git a/integration-tests/smallrye-reactive-messaging/src/main/java/org/apache/camel/quarkus/component/smallrye/reactive/messaging/it/FilesMessageConsumer.java b/integration-tests/smallrye-reactive-messaging/src/main/java/org/apache/camel/quarkus/component/smallrye/reactive/messaging/it/FilesMessageConsumer.java
new file mode 100644
index 0000000..16250ba
--- /dev/null
+++ b/integration-tests/smallrye-reactive-messaging/src/main/java/org/apache/camel/quarkus/component/smallrye/reactive/messaging/it/FilesMessageConsumer.java
@@ -0,0 +1,56 @@
+/*
+ * 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.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CompletionStage;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.file.GenericFile;
+import org.eclipse.microprofile.reactive.messaging.Incoming;
+import org.eclipse.microprofile.reactive.messaging.Message;
+
+@Singleton
+public class FilesMessageConsumer {
+
+    private List<String> fileBodies = new ArrayList<>();
+
+    @Inject
+    CamelContext context;
+
+    @Incoming("files")
+    public CompletionStage<Void> consumeFile(Message<GenericFile<File>> msg) {
+        try {
+            GenericFile<File> file = msg.getPayload();
+            String content = context.getTypeConverter().convertTo(String.class, file);
+            fileBodies.add(content);
+            return msg.ack();
+        } catch (Exception e) {
+            e.printStackTrace();
+            return msg.nack(e);
+        }
+    }
+
+    public List<String> getFileBodies() {
+        return fileBodies;
+    }
+}
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
index 3e90518..210d157 100644
--- 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
@@ -40,6 +40,9 @@ public class SmallRyeReactiveMessagingResource {
     @Inject
     ResultsBean results;
 
+    @Inject
+    FilesMessageConsumer filesMessageConsumer;
+
     @Path("/post")
     @Consumes(MediaType.TEXT_PLAIN)
     @POST
@@ -58,4 +61,12 @@ public class SmallRyeReactiveMessagingResource {
         Collections.sort(values);
         return String.join(",", values);
     }
+
+    @Path("/file")
+    @Produces(MediaType.TEXT_PLAIN)
+    @GET
+    public String getFiles() {
+        List<String> bodies = filesMessageConsumer.getFileBodies();
+        return String.join(",", bodies);
+    }
 }
diff --git a/integration-tests/smallrye-reactive-messaging/src/main/resources/application.properties b/integration-tests/smallrye-reactive-messaging/src/main/resources/application.properties
new file mode 100644
index 0000000..2295bb8
--- /dev/null
+++ b/integration-tests/smallrye-reactive-messaging/src/main/resources/application.properties
@@ -0,0 +1,18 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+mp.messaging.incoming.files.connector=smallrye-camel
+mp.messaging.incoming.files.endpoint-uri=file:./target/test/?delete=true&charset=utf-8
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
index 005910e..a65f280 100644
--- 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
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.quarkus.component.smallrye.reactive.messaging.it;
 
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -69,4 +71,20 @@ class SmallRyeReactiveMessagingTest {
             return response.equals("A,B,C,D");
         });
     }
+
+    @Test
+    public void testPropertiesConfiguredFileConsumer() throws IOException {
+        String content = "Hello Camel Quarkus Reactive Streams Messaging";
+        Files.write(Paths.get("target/test/test.txt"), content.getBytes(StandardCharsets.UTF_8));
+
+        await().atMost(10, TimeUnit.SECONDS).until(() -> {
+            String response = RestAssured.get("/smallrye-reactive-messaging/file")
+                    .then()
+                    .statusCode(200)
+                    .extract()
+                    .body()
+                    .asString();
+            return response.equals(content);
+        });
+    }
 }
diff --git a/pom.xml b/pom.xml
index 9e68be4..e24561c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -75,7 +75,7 @@
         <quarkus-qpid-jms.version>0.18.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>
+        <smallrye.reactive.messaging.camel.version>2.4.0</smallrye.reactive.messaging.camel.version>
         <soap-api.version>1.4.0</soap-api.version><!-- keep in sync with Camel -->
         <!-- Keep spring.version aligned with the version used by Camel -->
         <spring.version>5.2.8.RELEASE</spring.version>