Class 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
    • 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.
      • 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 Detail

      • HeartbeatTask

        public HeartbeatTask​(io.micronaut.context.event.ApplicationEventPublisher eventPublisher,
                             HeartbeatConfiguration configuration,
                             CurrentHealthStatus currentHealthStatus)
        Parameters:
        eventPublisher - To publish the events related to heartbeat
        configuration - The configurations for heartbeat
        currentHealthStatus - 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 interface io.micronaut.context.event.ApplicationEventListener<ServiceReadyEvent>