You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2020/09/30 14:38:45 UTC

[GitHub] [camel] lburgazzoli commented on a change in pull request #4325: camel-platform-http-vertx: handle requests using a thread from the worker pool

lburgazzoli commented on a change in pull request #4325:
URL: https://github.com/apache/camel/pull/4325#discussion_r497563313



##########
File path: components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpConsumer.java
##########
@@ -163,6 +146,63 @@ private String configureEndpointPath(PlatformHttpEndpoint endpoint) {
         return PATH_PARAMETER_PATTERN.matcher(path).replaceAll(":$1");
     }
 
+    private void handleRequest(RoutingContext ctx) {
+        final Vertx vertx = ctx.vertx();
+        final Exchange exchange = toExchange(ctx);
+
+        //
+        // We do not know if any of the processing logic of the route is synchronous or not so we
+        // need to process the request on a thread on the Vert.x worker pool.
+        //
+        // As example, assuming the platform-http component is configured as the transport provider
+        // for the rest dsl, then the following code may result in a blocking operation that could
+        // block Vert.x event-loop for too long if the target service takes long to respond, as
+        // example in case the service is a knative service scaled to zero that could take some time
+        // to be come available:
+        //
+        //     rest("/results")
+        //         .get("/{id}")
+        //         .route()
+        //             .removeHeaders("*", "CamelHttpPath")
+        //             .to("rest:get:?bridgeEndpoint=true");
+        //
+        vertx.executeBlocking(
+                promise -> {
+                    try {
+                        createUoW(exchange);
+
+                        // no need to use an async processor as the processing happen in
+                        // a dedicated thread ans it won't block the Vert.x event loop
+                        getProcessor().process(exchange);

Review comment:
       @davsclaus something like: `getAsyncProcessor().process(exchange, c -> promise.complete());` ?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org