Class PubSubHealthIndicator

java.lang.Object
org.springframework.boot.actuate.health.AbstractHealthIndicator
com.google.cloud.spring.autoconfigure.pubsub.health.PubSubHealthIndicator
All Implemented Interfaces:
org.springframework.boot.actuate.health.HealthContributor, org.springframework.boot.actuate.health.HealthIndicator

public class PubSubHealthIndicator extends org.springframework.boot.actuate.health.AbstractHealthIndicator
Default implementation of HealthIndicator for Pub/Sub. Validates if connection is successful by pulling messages from the pubSubTemplate using PubSubTemplate.pullAsync(String, Integer, Boolean).

If a custom subscription has been specified, this health indicator will signal "up" if messages are successfully pulled and (optionally) acknowledged or if a successful pull is performed but no messages are returned from Pub/Sub.

If no subscription has been specified, this health indicator will pull messages from a random subscription that is expected not to exist. It will signal "up" if it is able to connect to GCP Pub/Sub APIs, i.e. the pull results in a response of StatusCode.Code.NOT_FOUND or StatusCode.Code.PERMISSION_DENIED.

Note that messages pulled from the subscription will not be acknowledged, unless you set the acknowledgeMessages option to "true". However, take care not to configure a subscription that has a business impact, or leave the custom subscription out completely.

Since:
1.2.2
  • Constructor Summary

    Constructors
    Constructor
    Description
    PubSubHealthIndicator(PubSubTemplate pubSubTemplate, String healthCheckSubscription, long timeoutMillis, boolean acknowledgeMessages)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    doHealthCheck(org.springframework.boot.actuate.health.Health.Builder builder)
     

    Methods inherited from class org.springframework.boot.actuate.health.AbstractHealthIndicator

    health

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.boot.actuate.health.HealthIndicator

    getHealth
  • Constructor Details

    • PubSubHealthIndicator

      public PubSubHealthIndicator(PubSubTemplate pubSubTemplate, String healthCheckSubscription, long timeoutMillis, boolean acknowledgeMessages)
  • Method Details

    • doHealthCheck

      protected void doHealthCheck(org.springframework.boot.actuate.health.Health.Builder builder)
      Specified by:
      doHealthCheck in class org.springframework.boot.actuate.health.AbstractHealthIndicator