Class PubSubHealthIndicator

All Implemented Interfaces:,

public class PubSubHealthIndicator extends
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.

  • Constructor Summary

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

    Modifier and Type
    protected void
    doHealthCheck( builder)

    Methods inherited from class


    Methods inherited from class java.lang.Object

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

    Methods inherited from interface

  • Constructor Details

    • PubSubHealthIndicator

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

    • doHealthCheck

      protected void doHealthCheck( builder)
      Specified by:
      doHealthCheck in class