gnodet-bot commented on code in PR #26733: URL: https://github.com/apache/camel/pull/26733#discussion_r4069950375
########## components/camel-debezium/camel-debezium-common/camel-debezium-common-component/src/main/java/org/apache/camel/component/debezium/DebeziumConsumerHealthCheck.java: ########## @@ -0,0 +1,90 @@ +/* + * 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.debezium; + +import java.util.Map; + +import org.apache.camel.health.HealthCheck; +import org.apache.camel.health.HealthCheckResultBuilder; +import org.apache.camel.util.URISupport; + +/** + * {@link HealthCheck} reporting the state of the embedded Debezium engine that backs a {@link DebeziumConsumer}. + * <p> + * The engine runs on its own thread and does not restart itself, so once it has stopped with an error the route no + * longer receives change events even though it is still started. This check turns the route DOWN in that case. + */ +public class DebeziumConsumerHealthCheck implements HealthCheck { + + private final DebeziumConsumer consumer; + private final String id; + private final String sanitizedUri; + private boolean enabled = true; Review Comment: 💡 **Optional consistency:** `ScheduledPollConsumerHealthCheck` uses `HealthCheckRegistry.getInitialState()` (typically `DOWN`) so that readiness probes stay `DOWN` until the consumer is confirmed healthy. The current field always initialises to `true` (UP), which means a readiness probe sees `UP` from the moment the route starts, before the engine has connected. For Debezium this is largely benign — the engine fails fast on a bad offset store or unreachable DB — but if you want to match the `ScheduledPollConsumer` convention: ```suggestion private boolean enabled = true; private HealthCheck.State initialState = HealthCheck.State.UP; ``` And in the constructor, after `this.sanitizedUri = ...`: ```java HealthCheckRegistry registry = HealthCheckRegistry.get(consumer.getEndpoint().getCamelContext()); if (registry != null) { this.initialState = registry.getInitialState(); } ``` And in `call()`, replace `return builder.up().build()` with `return builder.state(initialState).build()`. Not a blocker — raising for awareness. -- 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]
