gnodet opened a new pull request, #27505: URL: https://github.com/apache/camel/pull/27505
## Description Fixes a classic publish-before-subscribe race condition in `NatsConsumerIT.testConsumer()`. ### Root Cause `NatsConsumer.doStart()` submits the NATS subscription asynchronously via `executor.submit(new NatsConsumingTask(...))`. The `doStart()` method returns before the subscription is established on the NATS server. Since standard NATS has no message persistence, the test's `template.sendBody()` call could race ahead of `dispatcher.subscribe()` completing in the background thread, causing the message to be silently dropped. The previous `setAssertPeriod(5000)` workaround (commit 685e1a4) addressed false positives (spurious passes) but not the fundamental race — a message dropped before subscription is established can never be received regardless of how long we wait. ### Fix Add an Awaitility wait on `NatsConsumer.isActive()` before sending the message. `NatsConsumer.setActive(true)` is called at the end of `setupStandardNatsConsumer()` (after `dispatcher.subscribe()` completes), making `isActive()` the correct readiness signal. This mirrors the identical pattern already established in `NatsConsumerWithRedeliveryIT`. ### Changes - `NatsConsumerIT`: add `await().atMost(10, TimeUnit.SECONDS).until(...)` guard before `template.sendBody()`; drop the now-unnecessary `setAssertPeriod(5000)`. Fixes https://issues.apache.org/jira/browse/CAMEL-25342 -- 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]
