Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ public void testProducerBlocksResumeTest() throws Exception {
public void run() {
try {
// Wait for the main thread to enter TIMED_WAITING state
// (blocked on condition in DirectComponent.getConsumer)
await().atMost(2, TimeUnit.SECONDS)
// (blocked on condition in DirectComponent.getConsumer).
// Use a generous timeout — on slow CI the thread state
// detection can take longer than 2 s.
await().atMost(10, TimeUnit.SECONDS)
.pollInterval(10, TimeUnit.MILLISECONDS)
.until(() -> mainThread.getState() == Thread.State.TIMED_WAITING);

Expand All @@ -98,8 +100,10 @@ public void run() {
}
});

// This call will block until the route is resumed by the background thread
template.sendBody("direct:suspended?block=true&timeout=2000", "hello world");
// This call will block until the route is resumed by the background thread.
// Use a generous timeout so the background thread has enough headroom to
// detect the TIMED_WAITING state and resume the route even under CI load.
template.sendBody("direct:suspended?block=true&timeout=10000", "hello world");
Comment on lines 88 to +106

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the stacktrace sounds unrelated to the fact that it needs more time on these timeouts, it is complaining about no consumer available, which means the route with name suspended is not available

Caused by: org.apache.camel.component.direct.DirectConsumerNotAvailableException: No consumers available on endpoint: direct://suspended?block=true&timeout=2000. Exchange[]

https://develocity.apache.org/s/qawauqqv5yvp6/tests/goal/org.apache.camel:camel-core:surefire:test@default-test/details/org.apache.camel.component.direct.DirectProducerBlockingTest/testProducerBlocksResumeTest?top-execution=1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code on behalf of gnodet

The DirectConsumerNotAvailableException IS the manifestation of the timeout expiring. Here is the sequence:

  1. template.sendBody("direct:suspended?block=true&timeout=2000", ...) blocks in DirectComponent.getConsumer(), waiting for a consumer to become available (the route is suspended)
  2. A background thread uses Awaitility to wait until the main thread enters TIMED_WAITING state, then calls context.resumeRoute("suspended")
  3. If step 2 takes longer than the timeout=2000 parameter, the getConsumer() call times out and throws DirectConsumerNotAvailableException — because the route was not resumed in time

So the "no consumer available" error IS the timeout — the consumer never became available within the 2s window. On slow CI, the background thread's await().atMost(2s) can itself expire or the resumeRoute() can take long enough that the 2s sendBody timeout is exhausted.

The fix raises both timeouts (background Awaitility and sendBody) from 2s to 10s, giving CI enough headroom. The test logic remains identical — it still verifies that block=true correctly waits for a suspended route to resume.


assertMockEndpointsSatisfied();

Expand Down