davsclaus commented on code in PR #28049:
URL: https://github.com/apache/camel/pull/28049#discussion_r4307398068


##########
components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConnection.java:
##########
@@ -81,14 +98,40 @@ public OpcUaClient getOpcUaClient() {
     }
 
     protected void init() {
-        this.manager = new SubscriptionManager(this.configuration, 
Stack.sharedScheduledExecutor(), 10_000);
+        ObjectHelper.notNull(this.camelContext, "camelContext");
+
+        // A failed request disconnects the client, which can wait for a 
reconnect attempt that Milo schedules on its shared
+        // scheduled executor, so this connection handles its requests and 
reconnects on an executor of its own.
+        final ThreadPoolProfile profile = new ThreadPoolProfile("MiloClient");
+        // as many threads as that executor; with one processor or with 
virtual threads this is one thread, so a route
+        // that continues on it after an awaited request must not wait for 
another request of this connection
+        profile.setPoolSize(Runtime.getRuntime().availableProcessors());

Review Comment:
   Not blocking: this gives each connection a pool as large as Milo's JVM-wide 
one. The threads of a `ScheduledThreadPoolExecutor` never time out when idle, 
because Camel's scheduled pool factory ignores `keepAliveTime` and 
`allowCoreThreadTimeOut`. Each submitted task also starts a new thread until 
the pool reaches its core size. So a gateway with 8 processors and 30 PLC 
connections ends up with 240 idle `MiloClient` threads, where main had 8 in 
total. With virtual threads it is the other way round: one worker per 
connection, so after awaited requests the rest of every route on that 
connection runs on that single thread, one at a time.
   
   The upgrade guide already describes this, so it is fine for this PR. If it 
turns out to matter, a follow-up could split the two jobs: a small scheduled 
pool for the reconnect job, and a cached pool for the request completions (one 
thread per task with virtual threads). Idle threads of a cached pool time out, 
as they do in Milo's own client executor.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to