davsclaus commented on code in PR #21209:
URL: https://github.com/apache/camel/pull/21209#discussion_r2753283768
##########
components/camel-google/camel-google-pubsub-lite/src/main/java/org/apache/camel/component/google/pubsublite/GooglePubsubLiteConsumer.java:
##########
@@ -107,20 +107,40 @@ public void run() {
= new
CamelMessageReceiver(GooglePubsubLiteConsumer.this, endpoint, processor);
Subscriber subscriber =
endpoint.getComponent().getSubscriber(messageReceiver, endpoint);
+ boolean subscriberAdded = false;
try {
- subscribers.add(subscriber);
subscriber.startAsync().awaitRunning();
+ // Only add to list after successful startup
+ subscribers.add(subscriber);
+ subscriberAdded = true;
subscriber.awaitTerminated();
} catch (Exception e) {
localLog.error("Failure getting messages from PubSub
Lite", e);
+ // Remove from list if it was added
+ if (subscriberAdded) {
+ subscribers.remove(subscriber);
+ }
+
// allow camel error handler to be aware
if (endpoint.isBridgeErrorHandler()) {
getExceptionHandler().handleException(e);
}
+
+ // Add backoff delay to prevent tight loop on
persistent failures
+ try {
+ Thread.sleep(5000); // 5 second backoff
Review Comment:
We have a background task API for reconnecting that is better than thread
sleep. Though this is okay but ideally we should use that task api instead
see for example PgEventConsumer
--
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]