gnodet-bot commented on code in PR #31114:
URL: https://github.com/apache/camel/pull/31114#discussion_r4736498499
##########
components/camel-zookeeper-master/src/test/java/org/apache/camel/component/zookeepermaster/policy/MasterRoutePolicyRouteLifecycleTest.java:
##########
@@ -390,9 +391,15 @@ private static boolean isConsumerStarted(CamelContext
context) {
return ServiceHelper.isStarted(consumer);
}
+ // a consumer that is starting (ServiceHelper.isStarted) may not be ready
yet: the seda consumer replaces the stale
+ // queue of its endpoint when it starts, so a message sent before it has
started may be lost
+ private static boolean isConsumerFullyStarted(CamelContext context) {
+ return context.getRoute(ROUTE).getConsumer() instanceof
StatefulService consumer && consumer.isStarted();
Review Comment:
The `instanceof` pattern here doubles as a null guard — if `getConsumer()`
returns `null` (route not fully wired yet), the match fails and the method
returns `false`, deferring `awaitConsuming` to retry. Since `SedaConsumer`
extends `DefaultConsumer extends ServiceSupport implements StatefulService`,
the cast always succeeds once a consumer exists. Worth a brief note in the
comment that the `instanceof` also handles the case where the consumer isn't
attached yet.
--
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]