class SchedulerStartHandler {

    @Bean
    @Order(Ordered.HIGHEST_PRECEDENCE) // want this at the very beginning of scheduler start
    @IsSendingAsyncMessage(MessageID.SCHEDULER_STARTED)
    @UseCaseAdministratorReceivesNotificationAboutNewchedulerInstanceStart(@Step(number = 1, name = "send domain message that new scheduler instance has been started and information about potential zombie jobs"))
    public CommandLineRunner schedulerHasBeenStarted() {
        return args -> {
            LOG.info("scheduler has been started - inspect zombie job status and send event");
            List<ScheduleSecHubJob> jobsRunningButStartedBefore = repository.findAllRunningJobsStartedBefore(LocalDateTime.now());
            String information = buildZombieInformation(jobsRunningButStartedBefore);

            DomainMessage request = new DomainMessage(MessageID.SCHEDULER_STARTED);

            ClusterMemberMessage status = new ClusterMemberMessage();
            status.setHostName(hostnameBuilder.buildHostname());
            status.setServiceName("scheduler");
            status.setServiceStatus("starting");
            status.setInformation(information);

            request.set(MessageDataKeys.ENVIRONMENT_CLUSTER_MEMBER_STATUS, status);
            request.set(MessageDataKeys.ENVIRONMENT_BASE_URL, environment.getServerBaseUrl());
            eventBus.sendAsynchron(request);
        };
    }

}