Package io.micronaut.health
Class HeartbeatTask
java.lang.Object
io.micronaut.health.HeartbeatTask
- All Implemented Interfaces:
ApplicationEventListener<ServiceReadyEvent>,EventListener
@Singleton
@HeartbeatEnabled
public class HeartbeatTask
extends Object
implements ApplicationEventListener<ServiceReadyEvent>
A scheduled task that sends a periodic heartbeat whilst the server is active.
- Since:
- 1.0
- Author:
- graemerocher
-
Constructor Summary
ConstructorsConstructorDescriptionHeartbeatTask(ApplicationEventPublisher eventPublisher, HeartbeatConfiguration configuration, CurrentHealthStatus currentHealthStatus) -
Method Summary
Modifier and TypeMethodDescriptionvoidHandle an application event.voidpulsate()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(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
Description copied from interface:ApplicationEventListenerHandle an application event.- Specified by:
onApplicationEventin interfaceApplicationEventListener<ServiceReadyEvent>- Parameters:
event- the event to respond to
-