Class PubSubHealthIndicator
- All Implemented Interfaces:
org.springframework.boot.actuate.health.HealthContributor
,org.springframework.boot.actuate.health.HealthIndicator
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
ConstructorDescriptionPubSubHealthIndicator
(PubSubTemplate pubSubTemplate, String healthCheckSubscription, long timeoutMillis, boolean acknowledgeMessages) -
Method Summary
Modifier and TypeMethodDescriptionprotected 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 classorg.springframework.boot.actuate.health.AbstractHealthIndicator
-