Skip to content

Commit

Permalink
fix(pubsub/google): don't restart when subscription doesn't exist (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwander authored Jun 18, 2018
1 parent 816e304 commit ad32e05
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,19 @@ public void stop() {
}

private void restart() {
try {
stop();
} catch (Exception e) {
log.warn("Failure stopping subscriber: ", e);
}

log.info("Waiting to restart Google Pubsub subscriber for {}", formatSubscriptionName(project, subscriptionName));
try {
// TODO: Use exponential backoff?
Thread.sleep(1000);
} catch (InterruptedException e) {
}

start();
}

Expand Down Expand Up @@ -216,7 +223,12 @@ private static class GooglePubsubFailureHandler extends ApiService.Listener {

@Override
public void failed(ApiService.State from, Throwable failure) {
log.error("Google Pubsub listener for subscription name {} failure caused by {}", subscriptionName, failure.getMessage());
if (failure.getMessage() != null && failure.getMessage().contains("NOT_FOUND")) {
log.error("Subscription name {} could not be found (will not retry): ", subscriptionName, failure);
return;
}

log.error("Google Pubsub listener for subscription name {} failure caused by: ", subscriptionName, failure);
subscriber.restart();
}
}
Expand Down

0 comments on commit ad32e05

Please sign in to comment.