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 1e02f4c  CAMEL-16263 camel-google-pubsub - Consumer does not recover 
from 500 series error from Google (#5617)
1e02f4c is described below

commit 1e02f4cfc58895e3382e6f05d615de43440e8055
Author: electrosaur <sramamoor...@guidewire.com>
AuthorDate: Wed Jun 2 06:44:15 2021 -0700

    CAMEL-16263 camel-google-pubsub - Consumer does not recover from 500 series 
error from Google (#5617)
    
    In the synchronous consumer, catch and log retryable ApiException-s in 
addition to IOExcepion-s.
    The synchronous consumer will still die on all other exceptions.
    
    Co-authored-by: Shankar Ramamoorthy <sramamoor...@borges.guidewire.com>
---
 .../apache/camel/component/google/pubsub/GooglePubsubConsumer.java | 7 +++++++
 1 file changed, 7 insertions(+)

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 a08b892..0a18279 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
@@ -22,6 +22,7 @@ import java.util.List;
 import java.util.concurrent.ExecutorService;
 
 import com.google.api.core.AbstractApiService;
+import com.google.api.gax.rpc.ApiException;
 import com.google.cloud.pubsub.v1.MessageReceiver;
 import com.google.cloud.pubsub.v1.Subscriber;
 import com.google.cloud.pubsub.v1.stub.SubscriberStub;
@@ -177,6 +178,12 @@ public class GooglePubsubConsumer extends DefaultConsumer {
                     }
                 } catch (IOException e) {
                     localLog.error("Failure getting messages from PubSub", e);
+                } catch (ApiException e) {
+                    if (e.isRetryable()) {
+                        localLog.error("Retryable API exception in getting 
messages from PubSub", e);
+                    } else {
+                        throw e;
+                    }
                 }
             }
         }

Reply via email to