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
ConstructorDescriptionHeartbeatTask
(ApplicationEventPublisher eventPublisher, HeartbeatConfiguration configuration, CurrentHealthStatus currentHealthStatus) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Handle an application event.void
pulsate()
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, wait
Methods 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:ApplicationEventListener
Handle an application event.- Specified by:
onApplicationEvent
in interfaceApplicationEventListener<ServiceReadyEvent>
- Parameters:
event
- the event to respond to
-