You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2025/08/18 05:43:57 UTC

(camel) branch main updated: CAMEL-22356: Allow Google PubSub consumer pass exception through error handler (#18921)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 25f4ae78e06 CAMEL-22356: Allow Google PubSub consumer pass exception through error handler (#18921)
25f4ae78e06 is described below

commit 25f4ae78e061f66fadeb2e94ab18d9f51e7203af
Author: Sean Shi <gu...@microsoft.com>
AuthorDate: Mon Aug 18 15:43:50 2025 +1000

    CAMEL-22356: Allow Google PubSub consumer pass exception through error handler (#18921)
---
 .../component/google/pubsub/GooglePubsubConsumer.java    | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/components/camel-google/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubConsumer.java b/components/camel-google/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubConsumer.java
index e83bebe362e..bd40d3e9bea 100644
--- a/components/camel-google/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubConsumer.java
+++ b/components/camel-google/camel-google-pubsub/src/main/java/org/apache/camel/component/google/pubsub/GooglePubsubConsumer.java
@@ -142,11 +142,16 @@ public class GooglePubsubConsumer extends DefaultConsumer {
                 }
 
                 localLog.debug("Exit run for subscription {}", subscriptionName);
-            } catch (InterruptedException e) {
-                Thread.currentThread().interrupt();
-                localLog.error("Failure getting messages from PubSub", e);
             } catch (Exception e) {
+                if (e instanceof InterruptedException) {
+                    Thread.currentThread().interrupt();
+                }
                 localLog.error("Failure getting messages from PubSub", e);
+
+                // allow camel error handler to be aware
+                if (endpoint.isBridgeErrorHandler()) {
+                    getExceptionHandler().handleException(e);
+                }
             }
         }
 
@@ -161,6 +166,11 @@ public class GooglePubsubConsumer extends DefaultConsumer {
                     subscriber.awaitTerminated();
                 } catch (Exception e) {
                     localLog.error("Failure getting messages from PubSub", e);
+
+                    // allow camel error handler to be aware
+                    if (endpoint.isBridgeErrorHandler()) {
+                        getExceptionHandler().handleException(e);
+                    }
                 } finally {
                     localLog.debug("Stopping async subscriber {}", subscriptionName);
                     subscriber.stopAsync();