Package io.micronaut.health
Class HeartbeatTask
java.lang.Object
io.micronaut.health.HeartbeatTask
- All Implemented Interfaces:
io.micronaut.context.event.ApplicationEventListener<ServiceReadyEvent>,EventListener
@Singleton
@HeartbeatEnabled
public class HeartbeatTask
extends Object
implements io.micronaut.context.event.ApplicationEventListener<ServiceReadyEvent>
A scheduled task that sends a periodic heartbeat whilst the server is active.
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionHeartbeatTask(io.micronaut.context.event.ApplicationEventPublisher eventPublisher, HeartbeatConfiguration configuration, CurrentHealthStatus currentHealthStatus) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidpulsate()Publish the heartbeat event with current health status.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.context.event.ApplicationEventListener
supports
-
Constructor Details
-
HeartbeatTask
public HeartbeatTask(io.micronaut.context.event.ApplicationEventPublisher eventPublisher, HeartbeatConfiguration configuration, CurrentHealthStatus currentHealthStatus) - Parameters:
eventPublisher- To publish the events related to heartbeatconfiguration- The configurations for heartbeatcurrentHealthStatus- The current status of health indicator
-
-
Method Details
-
pulsate
@Scheduled(fixedDelay="${micronaut.heartbeat.interval:15s}", initialDelay="${micronaut.heartbeat.initial-delay:5s}") public void pulsate()Publish the heartbeat event with current health status. -
onApplicationEvent
- Specified by:
onApplicationEventin interfaceio.micronaut.context.event.ApplicationEventListener<ServiceReadyEvent>
-