class PDSBatchTriggerService {

    @Scheduled(initialDelayString = "${sechub.pds.config.trigger.nextjob.initialdelay:" + DEFAULT_INITIAL_DELAY_MILLIS
            + "}", fixedDelayString = "${sechub.pds.config.trigger.nextjob.delay:" + DEFAULT_FIXED_DELAY_MILLIS + "}")
    @Transactional
    public void triggerExecutionOfNextJob() {
        if (!schedulingEnabled) {
            LOG.trace("Trigger execution of next job canceled, because scheduling disabled.");
            return;
        }
        LOG.trace("Trigger execution of next job started.");
        if (executionService.isQueueFull()) {
            LOG.debug("Execution service is not able to execute next job, so cancel here");
            return;
        }
        /* query does auto increment version here! */
        Optional<PDSJob> nextJob = repository.findNextJobToExecute();
        if (!nextJob.isPresent()) {
            LOG.trace("No next job present");
            return;
        }
        PDSJob pdsJob = nextJob.get();
        pdsJob.setState(PDSJobStatusState.QUEUED);

        /*
         * next is done async - so on leave of this methods PDS job version will be
         * updated + state set to queue, so no other POD will process this job again
         */
        executionService.addToExecutionQueueAsynchron(pdsJob.getUUID());

    }

}