[camel] branch exchange-factory updated: CAMEL-16222: PooledExchangeFactory experiment

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[camel] branch exchange-factory updated: CAMEL-16222: PooledExchangeFactory experiment

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

davsclaus pushed a commit to branch exchange-factory
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/exchange-factory by this push:
     new 0dc3992  CAMEL-16222: PooledExchangeFactory experiment
0dc3992 is described below

commit 0dc39929147351204ae03b85e00ecae58ca7aef8
Author: Claus Ibsen <[hidden email]>
AuthorDate: Tue Feb 23 09:59:52 2021 +0100

    CAMEL-16222: PooledExchangeFactory experiment
---
 .../platform/http/vertx/VertxPlatformHttpConsumer.java    | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpConsumer.java b/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpConsumer.java
index a65d4d4..4e1b805 100644
--- a/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpConsumer.java
+++ b/components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpConsumer.java
@@ -35,6 +35,7 @@ import io.vertx.ext.web.FileUpload;
 import io.vertx.ext.web.Route;
 import io.vertx.ext.web.RoutingContext;
 import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePattern;
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.attachment.AttachmentMessage;
@@ -65,6 +66,7 @@ public class VertxPlatformHttpConsumer extends DefaultConsumer {
     private Set<Method> methods;
     private String path;
     private Route route;
+    private VertxPlatformHttpRouter router;
 
     public VertxPlatformHttpConsumer(PlatformHttpEndpoint endpoint,
                                      Processor processor,
@@ -86,13 +88,13 @@ public class VertxPlatformHttpConsumer extends DefaultConsumer {
         super.doInit();
         methods = Method.parseList(getEndpoint().getHttpMethodRestrict());
         path = configureEndpointPath(getEndpoint());
+        router = VertxPlatformHttpRouter.lookup(getEndpoint().getCamelContext());
     }
 
     @Override
     protected void doStart() throws Exception {
         super.doStart();
 
-        final VertxPlatformHttpRouter router = VertxPlatformHttpRouter.lookup(getEndpoint().getCamelContext());
         final Route newRoute = router.route(path);
 
         if (!methods.equals(Method.getAll())) {
@@ -143,7 +145,7 @@ public class VertxPlatformHttpConsumer extends DefaultConsumer {
 
     private String configureEndpointPath(PlatformHttpEndpoint endpoint) {
         String path = endpoint.getPath();
-        if (endpoint.isMatchOnUriPrefix()) {
+        if (endpoint.isMatchOnUriPrefix() && !path.endsWith("*")) {
             path += "*";
         }
         // Transform from the Camel path param syntax /path/{key} to vert.x web's /path/:key
@@ -209,26 +211,25 @@ public class VertxPlatformHttpConsumer extends DefaultConsumer {
                         }
                     } finally {
                         doneUoW(exchange);
+                        releaseExchange(exchange, false);
                     }
                 });
     }
 
     private Exchange toExchange(RoutingContext ctx) {
-        final Exchange exchange = getEndpoint().createExchange();
+        final Exchange exchange = createExchange(false);
+        exchange.setPattern(ExchangePattern.InOut);
         final Message in = toCamelMessage(ctx, exchange);
-
         final String charset = ctx.parsedHeaders().contentType().parameter("charset");
         if (charset != null) {
             exchange.setProperty(Exchange.CHARSET_NAME, charset);
             in.setHeader(Exchange.HTTP_CHARACTER_ENCODING, charset);
         }
-
-        exchange.setIn(in);
         return exchange;
     }
 
     private Message toCamelMessage(RoutingContext ctx, Exchange exchange) {
-        final Message result = new DefaultMessage(exchange);
+        final Message result = exchange.getIn();
 
         final HeaderFilterStrategy headerFilterStrategy = getEndpoint().getHeaderFilterStrategy();
         populateCamelHeaders(ctx, result.getHeaders(), exchange, headerFilterStrategy);