You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2019/10/24 15:13:48 UTC

[camel-quarkus] 01/04: Fix #322 Make camel-attachments an optional dependency of platform-http

This is an automated email from the ASF dual-hosted git repository.

lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git

commit 3f48af64dec23b7649c94ba03204c8bbfbdfe679
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Wed Oct 23 10:58:04 2019 +0200

    Fix #322 Make camel-attachments an optional dependency of platform-http
---
 .../deployment/AttachmentsProcessor.java           | 19 ++++++++
 .../attachments/AttachmentsRecorder.java}          | 33 +++++++------
 .../attachments}/CamelFileDataSource.java          |  2 +-
 .../quarkus/core/deployment/BuildProcessor.java    | 25 ++++++++++
 .../core/deployment/UploadAttacherBuildItem.java   | 47 +++++++++++++++++++
 .../quarkus/core/CoreAttachmentsRecorder.java      | 42 +++++++++++++++++
 .../java/org/apache/camel/quarkus/core/Flags.java  |  1 +
 .../core/{Flags.java => UploadAttacher.java}       | 27 ++++++-----
 extensions/platform-http/deployment/pom.xml        |  4 --
 .../http/deployment/PlatformHttpProcessor.java     |  7 ++-
 extensions/platform-http/runtime/pom.xml           |  4 --
 .../http/runtime/PlatformHttpRecorder.java         |  8 +++-
 .../http/runtime/QuarkusPlatformHttpConsumer.java  | 54 ++++++++++------------
 .../http/runtime/QuarkusPlatformHttpEngine.java    |  7 ++-
 integration-tests/platform-http/pom.xml            |  4 ++
 15 files changed, 214 insertions(+), 70 deletions(-)

diff --git a/extensions/attachments/deployment/src/main/java/org/apache/camel/quarkus/component/attachments/deployment/AttachmentsProcessor.java b/extensions/attachments/deployment/src/main/java/org/apache/camel/quarkus/component/attachments/deployment/AttachmentsProcessor.java
index e679dbc..6e1ce60 100644
--- a/extensions/attachments/deployment/src/main/java/org/apache/camel/quarkus/component/attachments/deployment/AttachmentsProcessor.java
+++ b/extensions/attachments/deployment/src/main/java/org/apache/camel/quarkus/component/attachments/deployment/AttachmentsProcessor.java
@@ -16,7 +16,13 @@
  */
 package org.apache.camel.quarkus.component.attachments.deployment;
 
+import org.apache.camel.quarkus.component.attachments.AttachmentsRecorder;
+import org.apache.camel.quarkus.core.UploadAttacher;
+import org.apache.camel.quarkus.core.deployment.UploadAttacherBuildItem;
+
 import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.annotations.ExecutionTime;
+import io.quarkus.deployment.annotations.Record;
 import io.quarkus.deployment.builditem.FeatureBuildItem;
 
 class AttachmentsProcessor {
@@ -28,4 +34,17 @@ class AttachmentsProcessor {
         return new FeatureBuildItem(FEATURE);
     }
 
+    /**
+     * Produces the "real" {@link UploadAttacher} thus overriding the default no-op one produced by
+     * {@code camel-quarkus-core-deployment}.
+     *
+     * @param recorder the {@link AttachmentsRecorder}
+     * @return a new {@link UploadAttacherBuildItem}
+     */
+    @Record(ExecutionTime.STATIC_INIT)
+    @BuildStep
+    UploadAttacherBuildItem uploadAttacher(AttachmentsRecorder recorder) {
+        return new UploadAttacherBuildItem(recorder.creatUploadAttacher());
+    }
+
 }
diff --git a/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/PlatformHttpRecorder.java b/extensions/attachments/runtime/src/main/java/org/apache/camel/quarkus/component/attachments/AttachmentsRecorder.java
similarity index 51%
copy from extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/PlatformHttpRecorder.java
copy to extensions/attachments/runtime/src/main/java/org/apache/camel/quarkus/component/attachments/AttachmentsRecorder.java
index a3bf6b7..8485755 100644
--- a/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/PlatformHttpRecorder.java
+++ b/extensions/attachments/runtime/src/main/java/org/apache/camel/quarkus/component/attachments/AttachmentsRecorder.java
@@ -14,28 +14,31 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.quarkus.component.platform.http.runtime;
+package org.apache.camel.quarkus.component.attachments;
 
-import java.util.List;
+import java.io.File;
+
+import javax.activation.DataHandler;
+
+import org.apache.camel.Message;
+import org.apache.camel.attachment.AttachmentMessage;
+import org.apache.camel.quarkus.core.UploadAttacher;
+import org.jboss.logging.Logger;
 
 import io.quarkus.runtime.RuntimeValue;
 import io.quarkus.runtime.annotations.Recorder;
-import io.vertx.core.Handler;
-import io.vertx.ext.web.Router;
-import io.vertx.ext.web.RoutingContext;
-import org.apache.camel.component.platform.http.PlatformHttpComponent;
-import org.apache.camel.component.platform.http.spi.PlatformHttpEngine;
 
 @Recorder
-public class PlatformHttpRecorder {
-    public RuntimeValue<PlatformHttpEngine> createEngine(RuntimeValue<Router> router, List<Handler<RoutingContext>> handlers) {
-        return new RuntimeValue<>(new QuarkusPlatformHttpEngine(router.getValue(), handlers));
-    }
+public class AttachmentsRecorder {
 
-    public RuntimeValue<PlatformHttpComponent> createComponent(RuntimeValue<PlatformHttpEngine> engine) {
-        PlatformHttpComponent component = new PlatformHttpComponent();
-        component.setEngine(engine.getValue());
+    private static final Logger LOG = Logger.getLogger(AttachmentMessage.class);
 
-        return new RuntimeValue<>(component);
+    public RuntimeValue<UploadAttacher> creatUploadAttacher() {
+        return new RuntimeValue<>((File localFile, String fileName, Message message) -> {
+            LOG.tracef("Attaching file %s to message %s", fileName, message);
+            final AttachmentMessage am = message.getExchange().getMessage(AttachmentMessage.class);
+            am.addAttachment(fileName, new DataHandler(new CamelFileDataSource(localFile, fileName)));
+        });
     }
+
 }
diff --git a/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/CamelFileDataSource.java b/extensions/attachments/runtime/src/main/java/org/apache/camel/quarkus/component/attachments/CamelFileDataSource.java
similarity index 97%
rename from extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/CamelFileDataSource.java
rename to extensions/attachments/runtime/src/main/java/org/apache/camel/quarkus/component/attachments/CamelFileDataSource.java
index b90d26c..b2fbd10 100644
--- a/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/CamelFileDataSource.java
+++ b/extensions/attachments/runtime/src/main/java/org/apache/camel/quarkus/component/attachments/CamelFileDataSource.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.component.platform.http;
+package org.apache.camel.quarkus.component.attachments;
 
 import java.io.File;
 import javax.activation.FileDataSource;
diff --git a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java
index 33975db..9280764 100644
--- a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java
+++ b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java
@@ -35,6 +35,7 @@ import io.quarkus.deployment.recording.RecorderContext;
 import io.quarkus.runtime.RuntimeValue;
 import org.apache.camel.CamelContext;
 import org.apache.camel.RoutesBuilder;
+import org.apache.camel.quarkus.core.CoreAttachmentsRecorder;
 import org.apache.camel.quarkus.core.CamelConfig;
 import org.apache.camel.quarkus.core.CamelMain;
 import org.apache.camel.quarkus.core.CamelMainProducers;
@@ -42,6 +43,7 @@ import org.apache.camel.quarkus.core.CamelMainRecorder;
 import org.apache.camel.quarkus.core.CamelProducers;
 import org.apache.camel.quarkus.core.CamelRecorder;
 import org.apache.camel.quarkus.core.Flags;
+import org.apache.camel.quarkus.core.UploadAttacher;
 import org.apache.camel.spi.Registry;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -275,4 +277,27 @@ class BuildProcessor {
             recorder.start(shutdown, main.getInstance());
         }
     }
+
+    /**
+     * Build steps related to Camel Attachments.
+     */
+    public static class Attachments {
+
+        /**
+         * Produces an {@link UploadAttacherBuildItem} holding a no-op {@link UploadAttacher}.
+         * <p>
+         * Note that this {@link BuildStep} is effective only if {@code camel-quarkus-attachments} extension is not in
+         * the class path.
+         *
+         * @param recorder the {@link CoreAttachmentsRecorder}
+         * @return a new {@link UploadAttacherBuildItem}
+         */
+        @Overridable
+        @Record(value = ExecutionTime.STATIC_INIT, optional = true)
+        @BuildStep
+        UploadAttacherBuildItem uploadAttacher(CoreAttachmentsRecorder recorder) {
+            return new UploadAttacherBuildItem(recorder.createNoOpUploadAttacher());
+        }
+
+    }
 }
diff --git a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/UploadAttacherBuildItem.java b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/UploadAttacherBuildItem.java
new file mode 100644
index 0000000..b0944a5
--- /dev/null
+++ b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/UploadAttacherBuildItem.java
@@ -0,0 +1,47 @@
+/*
+ * 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.core.deployment;
+
+import org.apache.camel.quarkus.core.UploadAttacher;
+
+import io.quarkus.builder.item.SimpleBuildItem;
+import io.quarkus.runtime.RuntimeValue;
+
+/**
+ * Holds the {@link UploadAttacher} {@link RuntimeValue}.
+ * <p>
+ * There are two producers for this item:
+ * <ul>
+ * <li>The default one producing a no-op {@link UploadAttacher}
+ * <li>
+ * <li>The "real" one available in {@code camel-quarkus-attachments}
+ * extension</li>
+ * <ul>
+ * The "real" one is used only if the {@code camel-quarkus-attachments}
+ * extension is present in the class path.
+ */
+public final class UploadAttacherBuildItem extends SimpleBuildItem {
+    private final RuntimeValue<UploadAttacher> instance;
+
+    public UploadAttacherBuildItem(RuntimeValue<UploadAttacher> instance) {
+        this.instance = instance;
+    }
+
+    public RuntimeValue<UploadAttacher> getInstance() {
+        return instance;
+    }
+}
diff --git a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CoreAttachmentsRecorder.java b/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CoreAttachmentsRecorder.java
new file mode 100644
index 0000000..26fecd0
--- /dev/null
+++ b/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CoreAttachmentsRecorder.java
@@ -0,0 +1,42 @@
+/*
+ * 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.core;
+
+import java.io.File;
+
+import io.quarkus.runtime.RuntimeValue;
+import io.quarkus.runtime.annotations.Recorder;
+
+import org.apache.camel.Message;
+
+@Recorder
+public class CoreAttachmentsRecorder {
+
+    public RuntimeValue<UploadAttacher> createNoOpUploadAttacher() {
+        return new RuntimeValue<>((File localFile, String fileName, Message message) -> {
+            throw new RuntimeException(
+                String.format(
+                    "File %s will not be attached to message %s because camel-quarkus-attachments is not in the class path."
+                        + " You have several options to handle this situation:"
+                        + " (a) Add camel-quarkus-attachments dependency to your project if you want Camel to attach the uploads to Camel messages"
+                        + " (b) Disable the uploads altogether by setting quarkus.http.body.handle-file-uploads = false in your application.proprties"
+                        + " (c) Ignore this message because it is perhaps caused by clients out of your control",
+                    fileName,
+                    message));
+        });
+    }
+}
diff --git a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/Flags.java b/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/Flags.java
index 6e08969..e4d13c6 100644
--- a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/Flags.java
+++ b/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/Flags.java
@@ -30,4 +30,5 @@ public final class Flags {
             return ConfigProvider.getConfig().getOptionalValue("quarkus.camel.enable-main", Boolean.class).orElse(Boolean.TRUE);
         }
     }
+
 }
diff --git a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/Flags.java b/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/UploadAttacher.java
similarity index 59%
copy from extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/Flags.java
copy to extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/UploadAttacher.java
index 6e08969..98c2663 100644
--- a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/Flags.java
+++ b/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/UploadAttacher.java
@@ -16,18 +16,23 @@
  */
 package org.apache.camel.quarkus.core;
 
-import java.util.function.BooleanSupplier;
+import java.io.File;
 
-import org.eclipse.microprofile.config.ConfigProvider;
+import org.apache.camel.Message;
 
-public final class Flags {
-    private Flags() {
-    }
+/**
+ * Attaches file uploads to Camel {@link Message}s.
+ */
+public interface UploadAttacher {
+
+    /**
+     * Attach the uploaded file represented by the given {@code localFile} and {@code fileName} to the given
+     * {@code message}
+     *
+     * @param localFile the uploaded file stored locally
+     * @param fileName the name of the upload as sent by the client
+     * @param message the {@link Message} to attach the upload to
+     */
+    void attachUpload(File localFile, String fileName, Message message);
 
-    public static final class MainEnabled implements BooleanSupplier {
-        @Override
-        public boolean getAsBoolean() {
-            return ConfigProvider.getConfig().getOptionalValue("quarkus.camel.enable-main", Boolean.class).orElse(Boolean.TRUE);
-        }
-    }
 }
diff --git a/extensions/platform-http/deployment/pom.xml b/extensions/platform-http/deployment/pom.xml
index 35747a8..3e17778 100644
--- a/extensions/platform-http/deployment/pom.xml
+++ b/extensions/platform-http/deployment/pom.xml
@@ -50,10 +50,6 @@
         </dependency>
         <dependency>
             <groupId>org.apache.camel.quarkus</groupId>
-            <artifactId>camel-quarkus-attachments-deployment</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.camel.quarkus</groupId>
             <artifactId>camel-quarkus-platform-http</artifactId>
         </dependency>
 
diff --git a/extensions/platform-http/deployment/src/main/java/org/apache/camel/quarkus/component/platform/http/deployment/PlatformHttpProcessor.java b/extensions/platform-http/deployment/src/main/java/org/apache/camel/quarkus/component/platform/http/deployment/PlatformHttpProcessor.java
index 32ebe11..955a013 100644
--- a/extensions/platform-http/deployment/src/main/java/org/apache/camel/quarkus/component/platform/http/deployment/PlatformHttpProcessor.java
+++ b/extensions/platform-http/deployment/src/main/java/org/apache/camel/quarkus/component/platform/http/deployment/PlatformHttpProcessor.java
@@ -33,6 +33,8 @@ import org.apache.camel.quarkus.component.platform.http.runtime.PlatformHttpHand
 import org.apache.camel.quarkus.component.platform.http.runtime.PlatformHttpRecorder;
 import org.apache.camel.quarkus.component.platform.http.runtime.QuarkusPlatformHttpEngine;
 import org.apache.camel.quarkus.core.deployment.CamelRuntimeBeanBuildItem;
+import org.apache.camel.quarkus.core.deployment.UploadAttacherBuildItem;
+
 
 class PlatformHttpProcessor {
 
@@ -49,7 +51,8 @@ class PlatformHttpProcessor {
             PlatformHttpRecorder recorder,
             VertxWebRouterBuildItem router,
             BodyHandlerBuildItem bodyHandler,
-            List<FeatureBuildItem> features) {
+            List<FeatureBuildItem> features,
+            UploadAttacherBuildItem uploadAttacher) {
 
         List<Handler<RoutingContext>> handlers = new ArrayList<>();
 
@@ -68,7 +71,7 @@ class PlatformHttpProcessor {
         handlers.add(bodyHandler.getHandler());
 
         return new PlatformHttpEngineBuildItem(
-            recorder.createEngine(router.getRouter(), handlers)
+            recorder.createEngine(router.getRouter(), handlers, uploadAttacher.getInstance())
         );
     }
 
diff --git a/extensions/platform-http/runtime/pom.xml b/extensions/platform-http/runtime/pom.xml
index 30f7e93..f8d74b0 100644
--- a/extensions/platform-http/runtime/pom.xml
+++ b/extensions/platform-http/runtime/pom.xml
@@ -57,10 +57,6 @@
         </dependency>
         <dependency>
             <groupId>org.apache.camel.quarkus</groupId>
-            <artifactId>camel-quarkus-attachments</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.camel.quarkus</groupId>
             <artifactId>camel-quarkus-platform-http-component</artifactId>
         </dependency>
 
diff --git a/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/PlatformHttpRecorder.java b/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/PlatformHttpRecorder.java
index a3bf6b7..8e86b74 100644
--- a/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/PlatformHttpRecorder.java
+++ b/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/PlatformHttpRecorder.java
@@ -25,11 +25,15 @@ import io.vertx.ext.web.Router;
 import io.vertx.ext.web.RoutingContext;
 import org.apache.camel.component.platform.http.PlatformHttpComponent;
 import org.apache.camel.component.platform.http.spi.PlatformHttpEngine;
+import org.apache.camel.quarkus.core.UploadAttacher;
 
 @Recorder
 public class PlatformHttpRecorder {
-    public RuntimeValue<PlatformHttpEngine> createEngine(RuntimeValue<Router> router, List<Handler<RoutingContext>> handlers) {
-        return new RuntimeValue<>(new QuarkusPlatformHttpEngine(router.getValue(), handlers));
+    public RuntimeValue<PlatformHttpEngine> createEngine(
+        RuntimeValue<Router> router,
+        List<Handler<RoutingContext>> handlers,
+        RuntimeValue<UploadAttacher> uploadAttacher) {
+        return new RuntimeValue<>(new QuarkusPlatformHttpEngine(router.getValue(), handlers, uploadAttacher.getValue()));
     }
 
     public RuntimeValue<PlatformHttpComponent> createComponent(RuntimeValue<PlatformHttpEngine> engine) {
diff --git a/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java b/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java
index 1970aa6..a852ec1 100644
--- a/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java
+++ b/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpConsumer.java
@@ -31,8 +31,6 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 
-import javax.activation.DataHandler;
-
 import org.apache.camel.Consumer;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
@@ -40,11 +38,10 @@ import org.apache.camel.NoTypeConversionAvailableException;
 import org.apache.camel.Processor;
 import org.apache.camel.TypeConversionException;
 import org.apache.camel.TypeConverter;
-import org.apache.camel.attachment.AttachmentMessage;
-import org.apache.camel.component.platform.http.CamelFileDataSource;
 import org.apache.camel.component.platform.http.PlatformHttpComponent;
 import org.apache.camel.component.platform.http.PlatformHttpEndpoint;
 import org.apache.camel.component.platform.http.spi.Method;
+import org.apache.camel.quarkus.core.UploadAttacher;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.support.DefaultConsumer;
 import org.apache.camel.support.DefaultMessage;
@@ -75,14 +72,15 @@ public class QuarkusPlatformHttpConsumer extends DefaultConsumer {
     private final List<Handler<RoutingContext>> handlers;
     private Route route;
     private final String fileNameExtWhitelist;
+    private final UploadAttacher uploadAttacher;
 
-
-    public QuarkusPlatformHttpConsumer(PlatformHttpEndpoint endpoint, Processor processor, Router router, List<Handler<RoutingContext>> handlers) {
+    public QuarkusPlatformHttpConsumer(PlatformHttpEndpoint endpoint, Processor processor, Router router, List<Handler<RoutingContext>> handlers, UploadAttacher uploadAttacher) {
         super(endpoint, processor);
         this.router = router;
         this.handlers = handlers;
         String list = endpoint.getFileNameExtWhitelist();
         this.fileNameExtWhitelist = list == null ? list : list.toLowerCase(Locale.US);
+        this.uploadAttacher = uploadAttacher;
     }
 
     @Override
@@ -107,11 +105,9 @@ public class QuarkusPlatformHttpConsumer extends DefaultConsumer {
         newRoute.handler(
             ctx -> {
                 try {
-                    final PlatformHttpEndpoint endpoint = getEndpoint();
-                    final HeaderFilterStrategy headerFilterStrategy = endpoint.getHeaderFilterStrategy();
-                    final Exchange e = toExchange(ctx, endpoint.createExchange(), headerFilterStrategy, fileNameExtWhitelist);
+                    final Exchange e = toExchange(ctx);
                     getProcessor().process(e);
-                    writeResponse(ctx, e, headerFilterStrategy);
+                    writeResponse(ctx, e, getEndpoint().getHeaderFilterStrategy());
                 } catch (Exception e) {
                     LOG.debugf(e, "Could not handle '%s'", path);
                     ctx.fail(e);
@@ -158,7 +154,7 @@ public class QuarkusPlatformHttpConsumer extends DefaultConsumer {
 
         final TypeConverter tc = exchange.getContext().getTypeConverter();
 
-        //copy headers from Message to Response
+        // copy headers from Message to Response
         if (headerFilterStrategy != null) {
             for (Map.Entry<String, Object> entry : message.getHeaders().entrySet()) {
                 final String key = entry.getKey();
@@ -234,7 +230,7 @@ public class QuarkusPlatformHttpConsumer extends DefaultConsumer {
             final byte[] bytes = new byte[4096];
             try (InputStream in = (InputStream) body) {
                 int len;
-                while ((len = in.read(bytes))  >= 0) {
+                while ((len = in.read(bytes)) >= 0) {
                     final Buffer b = Buffer.buffer(len);
                     b.appendBytes(bytes, 0, len);
                     response.write(b);
@@ -257,8 +253,9 @@ public class QuarkusPlatformHttpConsumer extends DefaultConsumer {
 
     }
 
-    static Exchange toExchange(RoutingContext ctx, Exchange exchange, HeaderFilterStrategy headerFilterStrategy, String fileNameExtWhitelist) {
-        Message in = toCamelMessage(ctx, exchange, headerFilterStrategy, fileNameExtWhitelist);
+    Exchange toExchange(RoutingContext ctx) {
+        final Exchange exchange = getEndpoint().createExchange();
+        Message in = toCamelMessage(ctx, exchange);
 
         final String charset = ctx.parsedHeaders().contentType().parameter("charset");
         if (charset != null) {
@@ -270,8 +267,11 @@ public class QuarkusPlatformHttpConsumer extends DefaultConsumer {
         return exchange;
     }
 
-    static void populateCamelHeaders(RoutingContext ctx, Map<String, Object> headersMap, Exchange exchange,
-            HeaderFilterStrategy headerFilterStrategy) {
+    static void populateCamelHeaders(
+        RoutingContext ctx,
+        Map<String, Object> headersMap,
+        Exchange exchange,
+        HeaderFilterStrategy headerFilterStrategy) {
 
         final HttpServerRequest request = ctx.request();
         headersMap.put(Exchange.HTTP_PATH, request.path());
@@ -330,10 +330,11 @@ public class QuarkusPlatformHttpConsumer extends DefaultConsumer {
         headersMap.put(Exchange.HTTP_RAW_QUERY, request.query());
     }
 
-    static Message toCamelMessage(RoutingContext ctx, Exchange exchange, HeaderFilterStrategy headerFilterStrategy, String fileNameExtWhitelist) {
-        Message result = new DefaultMessage(exchange);
+    Message toCamelMessage(RoutingContext ctx, Exchange exchange) {
+        final Message result = new DefaultMessage(exchange);
 
-        populateCamelHeaders(ctx, result.getHeaders(), exchange, headerFilterStrategy);
+        final HeaderFilterStrategy headerFilterStrategy = getEndpoint().getHeaderFilterStrategy();
+        populateCamelHeaders(ctx, result.getHeaders(), exchange, headerFilterStrategy );
         final String mimeType = ctx.parsedHeaders().contentType().value();
         final boolean isMultipartFormData = "multipart/form-data".equals(mimeType);
         if ("application/x-www-form-urlencoded".equals(mimeType) || isMultipartFormData) {
@@ -341,8 +342,7 @@ public class QuarkusPlatformHttpConsumer extends DefaultConsumer {
             final Map<String, Object> body = new HashMap<>();
             for (String key : formData.names()) {
                 for (String value : formData.getAll(key)) {
-                    if (headerFilterStrategy != null
-                        && !headerFilterStrategy.applyFilterToExternalHeaders(key, value, exchange)) {
+                    if (headerFilterStrategy != null && !headerFilterStrategy.applyFilterToExternalHeaders(key, value, exchange)) {
                         appendHeader(result.getHeaders(), key, value);
                         appendHeader(body, key, value);
                     }
@@ -350,7 +350,7 @@ public class QuarkusPlatformHttpConsumer extends DefaultConsumer {
             }
             result.setBody(body);
             if (isMultipartFormData) {
-                populateAttachments(ctx, result, fileNameExtWhitelist);
+                populateAttachments(ctx.fileUploads(), result);
             }
         } else {
             //extract body by myself if undertow parser didn't handle and the method is allowed to have one
@@ -384,9 +384,7 @@ public class QuarkusPlatformHttpConsumer extends DefaultConsumer {
         headers.put(key, value);
     }
 
-    static void populateAttachments(RoutingContext ctx, Message message, String fileNameExtWhitelist) {
-        final Set<FileUpload> uploads = ctx.fileUploads();
-
+    void populateAttachments(Set<FileUpload> uploads, Message message) {
         for (FileUpload upload : uploads) {
             final String name = upload.name();
             final String fileName = upload.fileName();
@@ -405,13 +403,11 @@ public class QuarkusPlatformHttpConsumer extends DefaultConsumer {
             }
             if (accepted) {
                 final File localFile = new File(upload.uploadedFileName());
-                final AttachmentMessage am = message.getExchange().getMessage(AttachmentMessage.class);
-                am.addAttachment(fileName, new DataHandler(new CamelFileDataSource(localFile, fileName)));
+                uploadAttacher.attachUpload(localFile, fileName, message);
             } else {
                 LOG.debugf("Cannot add file as attachment: %s because the file is not accepted according to fileNameExtWhitelist: %s", fileName, fileNameExtWhitelist);
             }
         }
     }
 
-
-}
\ No newline at end of file
+}
diff --git a/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpEngine.java b/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpEngine.java
index 3e44401..2e7db4d 100644
--- a/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpEngine.java
+++ b/extensions/platform-http/runtime/src/main/java/org/apache/camel/quarkus/component/platform/http/runtime/QuarkusPlatformHttpEngine.java
@@ -27,20 +27,23 @@ import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.component.platform.http.PlatformHttpEndpoint;
 import org.apache.camel.component.platform.http.spi.PlatformHttpEngine;
+import org.apache.camel.quarkus.core.UploadAttacher;
 
 
 public class QuarkusPlatformHttpEngine implements PlatformHttpEngine {
     private final Router router;
     private final List<Handler<RoutingContext>> handlers;
+    private final UploadAttacher uploadAttacher;
 
-    public QuarkusPlatformHttpEngine(Router router, List<Handler<RoutingContext>> handlers) {
+    public QuarkusPlatformHttpEngine(Router router, List<Handler<RoutingContext>> handlers, UploadAttacher uploadAttacher) {
         this.router = router;
         this.handlers = new ArrayList<>(handlers);
+        this.uploadAttacher = uploadAttacher;
     }
 
     @Override
     public Consumer createConsumer(PlatformHttpEndpoint endpoint, Processor processor) {
-        return new QuarkusPlatformHttpConsumer(endpoint, processor, router, handlers);
+        return new QuarkusPlatformHttpConsumer(endpoint, processor, router, handlers, uploadAttacher);
     }
 
     public List<Handler<RoutingContext>> getHandlers() {
diff --git a/integration-tests/platform-http/pom.xml b/integration-tests/platform-http/pom.xml
index 09a0d07..2b72ebd 100644
--- a/integration-tests/platform-http/pom.xml
+++ b/integration-tests/platform-http/pom.xml
@@ -44,6 +44,10 @@
             <groupId>org.apache.camel.quarkus</groupId>
             <artifactId>camel-quarkus-log</artifactId>
         </dependency>
+        <dependency><!-- Leave this one out (and save ~560 kB of the native image) unless you want to attach uploads to the camel message -->
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-attachments</artifactId>
+        </dependency>
 
         <!-- test dependencies -->
         <dependency>