Claus Ibsen created CAMEL-27294:
-----------------------------------

             Summary: camel-knative-http and camel-vertx-websocket - the route 
no longer holds a Vert.x worker thread while it waits for another thread
                 Key: CAMEL-27294
                 URL: https://issues.apache.org/jira/browse/CAMEL-27294
             Project: Camel
          Issue Type: Bug
          Components: camel-knative-http, camel-vertx-websocket
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Follow-up of CAMEL-27217 (PR https://github.com/apache/camel/pull/30468), which 
fixed this for camel-platform-http-vertx.

These consumers start the route in vertx.executeBlocking and run it with the 
synchronous processor, so the Vert.x worker thread waits (in the 
AsyncProcessorAwaitManager) until the whole route is complete:

* KnativeHttpConsumer (camel-knative-http): 
getAsyncProcessor().process(exchange), which is the blocking variant
* VertxWebsocketConsumer (camel-vertx-websocket): 
getProcessor().process(exchange)
* VertxWebsocketClientConsumer (camel-vertx-websocket): 
getProcessor().process(exchange)

When the route calls an asynchronous producer that needs a worker thread of the 
same Vert.x to complete its exchange (for example vertx-http, which completes 
in executeBlocking), and as many messages are in flight as there are worker 
threads (20 by default), every worker thread waits for its route and no 
producer completion gets a worker thread. The consumer then stops processing 
for good. This happens when the consumer and the producer share one Vert.x, 
such as a Vertx instance in the registry, or in Camel Quarkus.

Do the same as CAMEL-27217:
* Start the route on a worker thread, but with the asynchronous processor 
(process(exchange, callback)), so the worker thread is freed when the route 
continues on another thread.
* Complete the result on the original Vert.x context (context.runOnContext), so 
the reply / websocket handling still runs where it does today.
* Consider the same synchronous option (default false) to keep the current 
behaviour, where the worker thread runs the whole route and the worker pool 
limits the messages in flight.
* Vert.x 5 executeBlocking both fails its future and rethrows 
RejectedExecutionException when the worker pool is shut down, so wrap the call, 
so that the failure handler is always attached. The same applies to 
VertxPlatformHttpConsumer.processExchange (left open in #30468).

Add a test with a shared Vert.x with 2 worker threads and a route that calls 
vertx-http, as VertxPlatformHttpSharedVertxWorkerPoolTest does.




--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to