Package io.micronaut.health
Class HeartbeatTask
- java.lang.Object
-
- io.micronaut.health.HeartbeatTask
-
- All Implemented Interfaces:
io.micronaut.context.event.ApplicationEventListener<ServiceReadyEvent>
,java.util.EventListener
@Singleton @HeartbeatEnabled public class HeartbeatTask extends java.lang.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
Constructors Constructor Description HeartbeatTask(io.micronaut.context.event.ApplicationEventPublisher eventPublisher, HeartbeatConfiguration configuration, CurrentHealthStatus currentHealthStatus)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
onApplicationEvent(ServiceReadyEvent event)
void
pulsate()
Publish the heartbeat event with current health status.
-
-
-
Constructor Detail
-
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 Detail
-
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
public void onApplicationEvent(ServiceReadyEvent event)
- Specified by:
onApplicationEvent
in interfaceio.micronaut.context.event.ApplicationEventListener<ServiceReadyEvent>
-
-