public class PubSubHealthIndicator
extends org.springframework.boot.actuate.health.AbstractHealthIndicator
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 and Description |
---|
PubSubHealthIndicator(PubSubTemplate pubSubTemplate,
String healthCheckSubscription,
long timeoutMillis,
boolean acknowledgeMessages) |
Modifier and Type | Method and Description |
---|---|
protected void |
doHealthCheck(org.springframework.boot.actuate.health.Health.Builder builder) |
public PubSubHealthIndicator(PubSubTemplate pubSubTemplate, String healthCheckSubscription, long timeoutMillis, boolean acknowledgeMessages)
Copyright © 2021. All rights reserved.