This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 33e6b6cefd2f CAMEL-27443: camel-resilience4j - in synchronous mode
with a timeout, a full thread pool no longer runs the call on the route thread
(#30808)
33e6b6cefd2f is described below
commit 33e6b6cefd2fd3da05e510d8c55c33461b105726
Author: allthingssecurity <[email protected]>
AuthorDate: Thu Nov 26 13:28:54 2026 +0530
CAMEL-27443: camel-resilience4j - in synchronous mode with a timeout, a
full thread pool no longer runs the call on the route thread (#30808)
A Circuit Breaker with timeoutEnabled and without asynchronous runs its
calls on
a thread pool that Camel creates from the default thread pool profile,
which has
the CallerRuns rejected policy. When all the threads were busy and the
queue was
full, supplyAsync ran the call on the route thread before the time limiter
had a
future to wait on: the call could not time out, a backend that does not
answer
blocked the route thread for good, and the circuit breaker recorded the
call as
a success. The thread pool fills up during a slowdown, since a call that
timed
out keeps its thread, and a call that timed out while queued kept its queue
slot
until a thread took it.
The thread pool that Camel creates now uses the Abort rejected policy, so
such a
call fails with a RejectedExecutionException (or goes to the fallback) and
the
circuit breaker records a failure. A call that the time limiter cancels
while it
is queued is removed from the queue (ThreadPoolCall replaces supplyAsync).
With
virtual threads the thread pool is bounded by a semaphore: a call over the
bound
still waits up to the keep alive time for a free slot, and is then rejected
instead of running on the route thread. A thread pool given with
timeoutExecutorService keeps its own rejected policy (CallerRuns there
keeps the
old behaviour).
Docs: a paragraph on the Resilience4j EIP page (and its catalog copy) and an
upgrade guide entry for 4.24.
Found with a TLA+ model.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../camel/catalog/docs/resilience4j-eip.adoc | 11 +
.../resilience4j/ResilienceProcessor.java | 51 ++++-
.../component/resilience4j/ResilienceReifier.java | 11 +-
.../ResilienceSyncTimeoutThreadPoolFullTest.java | 242 +++++++++++++++++++++
.../docs/modules/eips/pages/resilience4j-eip.adoc | 11 +
.../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc | 23 ++
6 files changed, 345 insertions(+), 4 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/resilience4j-eip.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/resilience4j-eip.adoc
index 6d4650a58888..b177422ff72b 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/resilience4j-eip.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/resilience4j-eip.adoc
@@ -154,6 +154,17 @@ YAML::
In this example if calling the downstream service does not return a response
within 2 seconds,
a timeout is triggered, and the exchange will fail with a `TimeoutException`.
+The calls run on a thread pool of the Circuit Breaker, named `CircuitBreaker`,
that Camel creates from the
+default thread pool profile (10 threads, up to 20, and a queue of 1000 calls;
with virtual threads, up to 1000 calls
+at once). A call that timed out keeps its thread until the downstream service
answers, so when the service is slow the
+thread pool can fill up. Then the next call is rejected: the exchange fails
with a `RejectedExecutionException` (or the
+fallback runs), and the circuit breaker counts it as a failed call. With
virtual threads, the call first waits for a
+free slot up to the keep alive time of the profile (60 seconds by default),
and the timeout does not apply to that
+wait. To bound the calls in progress, enable the bulkhead with a
`bulkheadMaxConcurrentCalls` no larger than the queue
+size of the thread pool, or size the default thread pool profile for the load.
A thread pool of your own, given with
+`timeoutExecutorService`, is used with its own rejected policy: with
`CallerRuns`, a call that the full thread pool
+rejects runs on the caller thread, where the timeout does not apply.
+
=== Asynchronous (non-blocking) processing
By default, the Resilience4j circuit breaker processes exchanges synchronously,
diff --git
a/components/camel-resilience4j/src/main/java/org/apache/camel/component/resilience4j/ResilienceProcessor.java
b/components/camel-resilience4j/src/main/java/org/apache/camel/component/resilience4j/ResilienceProcessor.java
index 9f63ae581c1f..4ecf74dc3f98 100644
---
a/components/camel-resilience4j/src/main/java/org/apache/camel/component/resilience4j/ResilienceProcessor.java
+++
b/components/camel-resilience4j/src/main/java/org/apache/camel/component/resilience4j/ResilienceProcessor.java
@@ -26,6 +26,7 @@ import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.Lock;
@@ -634,7 +635,7 @@ public class ResilienceProcessor extends
BaseProcessorSupport
Callable<Exchange> callable;
if (timeLimiter != null) {
- Supplier<CompletionStage<Exchange>> stage = () ->
CompletableFuture.supplyAsync(ftask, executorService);
+ Supplier<CompletionStage<Exchange>> stage = () ->
ThreadPoolCall.start(ftask, executorService);
if (bulkhead != null) {
// the bulkhead goes inside the time limiter, so the
permit is held until the task is done,
// and not released when the timeout fires while the task
is still running
@@ -1010,6 +1011,54 @@ public class ResilienceProcessor extends
BaseProcessorSupport
}
}
+ /**
+ * A call of the synchronous mode with a timeout, run on the thread pool,
as {@code CompletableFuture.supplyAsync}
+ * does: a call that is cancelled before it starts is skipped. The time
limiter cancels the call when it times out,
+ * and a call cancelled while it waits in the queue of a {@link
ThreadPoolExecutor} is also removed from the queue,
+ * so the calls that timed out do not take the queue slots of the next
calls until a thread is free to skip them.
+ */
+ private static final class ThreadPoolCall extends
CompletableFuture<Exchange> implements Runnable {
+
+ private final Supplier<Exchange> task;
+ private final ThreadPoolExecutor threadPool;
+
+ private ThreadPoolCall(Supplier<Exchange> task, ThreadPoolExecutor
threadPool) {
+ this.task = task;
+ this.threadPool = threadPool;
+ }
+
+ /**
+ * Submits the call; throws {@code RejectedExecutionException} when
the thread pool rejects it (the thread pool
+ * that Camel creates rejects a call when all its threads are busy and
its queue is full).
+ */
+ static ThreadPoolCall start(Supplier<Exchange> task, ExecutorService
executorService) {
+ ThreadPoolCall call = new ThreadPoolCall(
+ task, executorService instanceof ThreadPoolExecutor tpe ?
tpe : null);
+ executorService.execute(call);
+ return call;
+ }
+
+ @Override
+ public void run() {
+ if (!isDone()) {
+ try {
+ complete(task.get());
+ } catch (Throwable e) {
+ completeExceptionally(e);
+ }
+ }
+ }
+
+ @Override
+ public boolean cancel(boolean mayInterruptIfRunning) {
+ boolean cancelled = super.cancel(mayInterruptIfRunning);
+ if (cancelled && threadPool != null) {
+ threadPool.remove(this);
+ }
+ return cancelled;
+ }
+ }
+
private final class CircuitBreakerFallbackTask implements
PooledExchangeTask, Function<Throwable, Exchange> {
private Exchange exchange;
diff --git
a/components/camel-resilience4j/src/main/java/org/apache/camel/component/resilience4j/ResilienceReifier.java
b/components/camel-resilience4j/src/main/java/org/apache/camel/component/resilience4j/ResilienceReifier.java
index 4b68a3bac165..bab075f5c238 100644
---
a/components/camel-resilience4j/src/main/java/org/apache/camel/component/resilience4j/ResilienceReifier.java
+++
b/components/camel-resilience4j/src/main/java/org/apache/camel/component/resilience4j/ResilienceReifier.java
@@ -44,10 +44,12 @@ import org.apache.camel.reifier.ProcessorReifier;
import org.apache.camel.spi.BeanIntrospection;
import org.apache.camel.spi.ExtendedPropertyConfigurerGetter;
import org.apache.camel.spi.PropertyConfigurer;
+import org.apache.camel.spi.ThreadPoolProfile;
import org.apache.camel.support.CamelContextHelper;
import org.apache.camel.support.PluginHelper;
import org.apache.camel.support.PropertyBindingSupport;
import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy;
import org.apache.camel.util.function.Suppliers;
public class ResilienceReifier extends
ProcessorReifier<CircuitBreakerDefinition> {
@@ -247,9 +249,12 @@ public class ResilienceReifier extends
ProcessorReifier<CircuitBreakerDefinition
.newDefaultScheduledThreadPool(this, "CircuitBreaker");
shutdownThreadPool = true;
} else {
- executorService = camelContext.getExecutorServiceManager()
- .newThreadPool(this, "CircuitBreaker",
-
camelContext.getExecutorServiceManager().getDefaultThreadPoolProfile());
+ // the default thread pool profile, but a call is rejected when
all the threads are busy and the queue is
+ // full: with CallerRuns (the default) the call would run on the
caller thread before the time limiter
+ // waits for it, so it would never time out
+ ThreadPoolProfile profile =
camelContext.getExecutorServiceManager().getDefaultThreadPoolProfile().clone();
+ profile.setRejectedPolicy(ThreadPoolRejectedPolicy.Abort);
+ executorService =
camelContext.getExecutorServiceManager().newThreadPool(this, "CircuitBreaker",
profile);
shutdownThreadPool = true;
}
diff --git
a/components/camel-resilience4j/src/test/java/org/apache/camel/component/resilience4j/ResilienceSyncTimeoutThreadPoolFullTest.java
b/components/camel-resilience4j/src/test/java/org/apache/camel/component/resilience4j/ResilienceSyncTimeoutThreadPoolFullTest.java
new file mode 100644
index 000000000000..ad8b618d4b89
--- /dev/null
+++
b/components/camel-resilience4j/src/test/java/org/apache/camel/component/resilience4j/ResilienceSyncTimeoutThreadPoolFullTest.java
@@ -0,0 +1,242 @@
+/*
+ * 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.component.resilience4j;
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import io.github.resilience4j.bulkhead.Bulkhead;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePropertyKey;
+import org.apache.camel.Processor;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.spi.ThreadPoolProfile;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+import static org.awaitility.Awaitility.await;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Synchronous mode with a timeout: when the thread pool that runs the calls
is full, a call must not run on the caller
+ * thread, where the time limiter cannot time it out. The default thread pool
profile (10/20 threads, a queue of 1000)
+ * is scaled down to one thread and a queue of one.
+ */
+class ResilienceSyncTimeoutThreadPoolFullTest extends CamelTestSupport {
+
+ private final CountDownLatch firstCallStarted = new CountDownLatch(1);
+ private final CountDownLatch release = new CountDownLatch(1);
+ private final List<String> backendThreads = new CopyOnWriteArrayList<>();
+ private final ExecutorService callers = Executors.newCachedThreadPool();
+ private final ThreadPoolExecutor userThreadPool = new ThreadPoolExecutor(
+ 1, 1, 0, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1), new
ThreadPoolExecutor.CallerRunsPolicy());
+
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext context = super.createCamelContext();
+ ThreadPoolProfile profile =
context.getExecutorServiceManager().getDefaultThreadPoolProfile();
+ profile.setPoolSize(1);
+ profile.setMaxPoolSize(1);
+ profile.setMaxQueueSize(1);
+ context.getRegistry().bind("userThreadPool", userThreadPool);
+ return context;
+ }
+
+ @AfterEach
+ void releaseBlockedCalls() {
+ release.countDown();
+ userThreadPool.shutdown();
+ callers.shutdownNow();
+ }
+
+ /**
+ * Sends from a thread of the test, as the thread pool of the producer
template comes from the scaled down profile
+ * too.
+ */
+ private Future<Exchange> send(String uri, Processor processor) {
+ return callers.submit(() -> template.send(uri, processor));
+ }
+
+ @Test
+ void testCallIsRejectedWhenTheThreadPoolIsFull() throws Exception {
+ ResilienceProcessor cb = context.getProcessor("cbLong",
ResilienceProcessor.class);
+ ThreadPoolExecutor threadPool = (ThreadPoolExecutor)
cb.getExecutorService();
+
+ // X1 holds the only thread, X2 waits in the queue: the thread pool is
full
+ Future<Exchange> x1 = send("direct:long", e ->
e.getIn().setHeader("block", true));
+ assertTrue(firstCallStarted.await(10, TimeUnit.SECONDS));
+ Future<Exchange> x2 = send("direct:long", e ->
e.getIn().setBody("X2"));
+ await().atMost(10, TimeUnit.SECONDS).until(() ->
threadPool.getQueue().size() == 1);
+
+ // X3 fails at once instead of running on this thread
+ Exchange x3 = template.send("direct:long", e ->
e.getIn().setBody("X3"));
+
+ assertFalse(backendThreads.contains(Thread.currentThread().getName()),
"X3 ran on the caller thread");
+ assertEquals(1, backendThreads.size(), "only X1 has reached the
backend");
+ assertInstanceOf(RejectedExecutionException.class, x3.getException());
+ assertEquals(Boolean.FALSE,
x3.getProperty(ExchangePropertyKey.CIRCUIT_BREAKER_RESPONSE_SUCCESSFUL_EXECUTION));
+ assertEquals(1, cb.getNumberOfFailedCalls(), "the breaker records the
rejected call as a failure");
+ assertEquals(0, cb.getNumberOfSuccessfulCalls());
+ assertEquals(0, cb.getNumberOfTimedOutCalls());
+ assertEquals(0, cb.getNumberOfBulkheadRejectedCalls());
+
+ // the calls in the thread pool complete as usual
+ release.countDown();
+ assertNull(x1.get(10, TimeUnit.SECONDS).getException());
+ assertNull(x2.get(10, TimeUnit.SECONDS).getException());
+ assertEquals(2, cb.getNumberOfSuccessfulCalls());
+ }
+
+ @Test
+ void testRejectedCallGoesToTheFallbackAndReleasesTheBulkheadPermit()
throws Exception {
+ ResilienceProcessor cb = context.getProcessor("cbBulkhead",
ResilienceProcessor.class);
+ ThreadPoolExecutor threadPool = (ThreadPoolExecutor)
cb.getExecutorService();
+ Bulkhead bulkhead = cb.getBulkheadRegistry().bulkhead("cbBulkhead");
+
+ Future<Exchange> x1 = send("direct:bulkhead", e ->
e.getIn().setHeader("block", true));
+ assertTrue(firstCallStarted.await(10, TimeUnit.SECONDS));
+ Future<Exchange> x2 = send("direct:bulkhead", e ->
e.getIn().setBody("X2"));
+ await().atMost(10, TimeUnit.SECONDS).until(() ->
threadPool.getQueue().size() == 1);
+
+ // the bulkhead lets X3 in, the full thread pool rejects it, and the
fallback answers
+ Exchange x3 = template.send("direct:bulkhead", e ->
e.getIn().setBody("X3"));
+
+ assertFalse(backendThreads.contains(Thread.currentThread().getName()),
"X3 ran on the caller thread");
+ assertNull(x3.getException());
+ assertEquals("Fallback", x3.getMessage().getBody());
+ assertEquals(Boolean.TRUE,
x3.getProperty(ExchangePropertyKey.CIRCUIT_BREAKER_RESPONSE_FROM_FALLBACK));
+ assertEquals(8, bulkhead.getMetrics().getAvailableConcurrentCalls(),
"X3 released its bulkhead permit");
+ assertEquals(1, cb.getNumberOfFailedCalls());
+ assertEquals(1, cb.getNumberOfFallbackCalls());
+ assertEquals(0, cb.getNumberOfTimedOutCalls());
+ assertEquals(0, cb.getNumberOfBulkheadRejectedCalls());
+
+ release.countDown();
+ assertEquals("Bye", x1.get(10,
TimeUnit.SECONDS).getMessage().getBody());
+ assertEquals("Bye", x2.get(10,
TimeUnit.SECONDS).getMessage().getBody());
+ }
+
+ @Test
+ void testTimedOutCallLeavesTheQueue() throws Exception {
+ ResilienceProcessor cb = context.getProcessor("cbShort",
ResilienceProcessor.class);
+ ThreadPoolExecutor threadPool = (ThreadPoolExecutor)
cb.getExecutorService();
+
+ // X1 times out and keeps the only thread (the backend does not answer)
+ Future<Exchange> x1 = send("direct:short", e ->
e.getIn().setHeader("block", true));
+ assertTrue(firstCallStarted.await(10, TimeUnit.SECONDS));
+ assertInstanceOf(TimeoutException.class, x1.get(10,
TimeUnit.SECONDS).getException());
+
+ // X2 times out while it waits in the queue, and leaves the queue
+ Exchange x2 = template.send("direct:short", e ->
e.getIn().setBody("X2"));
+ assertInstanceOf(TimeoutException.class, x2.getException());
+ assertEquals(0, threadPool.getQueue().size(), "the timed-out call X2
still takes the queue slot");
+
+ // X3 waits in the queue too, and times out: it does not run on this
thread
+ Exchange x3 = template.send("direct:short", e ->
e.getIn().setBody("X3"));
+ assertInstanceOf(TimeoutException.class, x3.getException());
+ assertFalse(backendThreads.contains(Thread.currentThread().getName()),
"X3 ran on the caller thread");
+ assertEquals(1, backendThreads.size(), "only X1 has reached the
backend");
+ assertEquals(0, threadPool.getQueue().size());
+ assertEquals(3, cb.getNumberOfFailedCalls());
+ assertEquals(0, cb.getNumberOfSuccessfulCalls());
+ assertEquals(3, cb.getNumberOfTimedOutCalls());
+ }
+
+ @Test
+ void testUserThreadPoolKeepsItsRejectedPolicy() throws Exception {
+ // a timeoutExecutorService of the user is used as it is: its
CallerRunsPolicy runs X3 on the caller thread
+ Future<Exchange> x1 = send("direct:user", e ->
e.getIn().setHeader("block", true));
+ assertTrue(firstCallStarted.await(10, TimeUnit.SECONDS));
+ Future<Exchange> x2 = send("direct:user", e ->
e.getIn().setBody("X2"));
+ await().atMost(10, TimeUnit.SECONDS).until(() ->
userThreadPool.getQueue().size() == 1);
+
+ Exchange x3 = template.send("direct:user", e ->
e.getIn().setBody("X3"));
+
+ assertNull(x3.getException());
+ assertEquals("Bye", x3.getMessage().getBody());
+ assertEquals(Thread.currentThread().getName(), backendThreads.get(1));
+
+ release.countDown();
+ assertNull(x1.get(10, TimeUnit.SECONDS).getException());
+ assertNull(x2.get(10, TimeUnit.SECONDS).getException());
+ }
+
+ private Processor backend() {
+ return e -> {
+ backendThreads.add(Thread.currentThread().getName());
+ if (e.getIn().getHeader("block", false, Boolean.class)) {
+ firstCallStarted.countDown();
+ // a backend that does not answer, until the test releases it
+ assertTrue(release.await(30, TimeUnit.SECONDS));
+ }
+ e.getMessage().setBody("Bye");
+ };
+ }
+
+ @Override
+ protected RoutesBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:short")
+ .circuitBreaker().id("cbShort")
+
.resilience4jConfiguration().timeoutEnabled(true).timeoutDuration("200ms").end()
+ .process(backend())
+ .end();
+
+ // a timeout that the calls of the test do not reach, so X2
stays in the queue
+ from("direct:long")
+ .circuitBreaker().id("cbLong")
+
.resilience4jConfiguration().timeoutEnabled(true).timeoutDuration("30s").end()
+ .process(backend())
+ .end();
+
+ from("direct:bulkhead")
+ .circuitBreaker().id("cbBulkhead")
+
.resilience4jConfiguration().timeoutEnabled(true).timeoutDuration("30s")
+
.bulkheadEnabled(true).bulkheadMaxConcurrentCalls(10).end()
+ .process(backend())
+ .onFallback()
+ .transform().constant("Fallback")
+ .end();
+
+ from("direct:user")
+ .circuitBreaker().id("cbUser")
+
.resilience4jConfiguration().timeoutEnabled(true).timeoutDuration("30s")
+ .timeoutExecutorService("userThreadPool").end()
+ .process(backend())
+ .end();
+ }
+ };
+ }
+}
diff --git
a/core/camel-core-engine/src/main/docs/modules/eips/pages/resilience4j-eip.adoc
b/core/camel-core-engine/src/main/docs/modules/eips/pages/resilience4j-eip.adoc
index 6d4650a58888..b177422ff72b 100644
---
a/core/camel-core-engine/src/main/docs/modules/eips/pages/resilience4j-eip.adoc
+++
b/core/camel-core-engine/src/main/docs/modules/eips/pages/resilience4j-eip.adoc
@@ -154,6 +154,17 @@ YAML::
In this example if calling the downstream service does not return a response
within 2 seconds,
a timeout is triggered, and the exchange will fail with a `TimeoutException`.
+The calls run on a thread pool of the Circuit Breaker, named `CircuitBreaker`,
that Camel creates from the
+default thread pool profile (10 threads, up to 20, and a queue of 1000 calls;
with virtual threads, up to 1000 calls
+at once). A call that timed out keeps its thread until the downstream service
answers, so when the service is slow the
+thread pool can fill up. Then the next call is rejected: the exchange fails
with a `RejectedExecutionException` (or the
+fallback runs), and the circuit breaker counts it as a failed call. With
virtual threads, the call first waits for a
+free slot up to the keep alive time of the profile (60 seconds by default),
and the timeout does not apply to that
+wait. To bound the calls in progress, enable the bulkhead with a
`bulkheadMaxConcurrentCalls` no larger than the queue
+size of the thread pool, or size the default thread pool profile for the load.
A thread pool of your own, given with
+`timeoutExecutorService`, is used with its own rejected policy: with
`CallerRuns`, a call that the full thread pool
+rejects runs on the caller thread, where the timeout does not apply.
+
=== Asynchronous (non-blocking) processing
By default, the Resilience4j circuit breaker processes exchanges synchronously,
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index 6320adc7e621..aef2f9421cc8 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -2943,6 +2943,29 @@ thread dumps and JMX change:
Breaker no longer ran: in synchronous mode each call timed out (into the
fallback, when there is one), and in
asynchronous mode the exchange never completed.
+=== camel-resilience4j - a full thread pool rejects a call of the synchronous
mode with a timeout
+
+A Circuit Breaker with `timeoutEnabled` and without `asynchronous` runs its
calls on a thread pool that Camel creates
+from the default thread pool profile (10 threads, up to 20, and a queue of
1000 calls). When all its threads were busy
+and its queue was full, the call ran on the caller thread (the `CallerRuns`
policy of the profile) before the timeout
+started: the call could not time out, a service that does not answer blocked
the route thread for good, and the
+circuit breaker counted the call as successful, however long it took. Now the
thread pool rejects the call: the
+exchange fails with a `RejectedExecutionException`, or the fallback runs, and
the circuit breaker counts it as a
+failed call. The rejected policy of the default thread pool profile is not
used for this thread pool.
+
+A call that times out while it waits in the queue now leaves the queue at
once. Before, it kept its slot until a
+thread took it from the queue, so during a slowdown the queue filled with
calls that had already timed out.
+
+With virtual threads (`camel.threads.virtual.enabled`), the thread pool runs
up to 1000 calls at once (the queue size
+of the profile). A call over that waits for a free slot up to the keep alive
time of the profile (60 seconds by
+default), as before, and is then rejected, where before it ran on the caller
thread.
+
+A thread pool given with `timeoutExecutorService` keeps its own rejected
policy. To keep the thread pool from filling
+up, enable the bulkhead with `bulkheadMaxConcurrentCalls` no larger than the
queue size of the thread pool, or size the
+default thread pool profile for the load. To run such a call on the caller
thread as before, give the Circuit Breaker
+a thread pool with the `CallerRuns` rejected policy with
`timeoutExecutorService` (a thread pool bean, or the id of a
+thread pool profile).
+
=== camel-jbang - camel cmd send without a name sends to the integration that
runs
`camel cmd send` without an integration name started a Camel of its own,
without routes, and sent from there. That is