#1017: CronNightlyJob.kt

projectforge-business/src/main/kotlin/org/projectforge/business/jobs/CronNightlyJob.kt Scheduled Job, projectforge-business/src/main/kotlin/org/projectforge/business/jobs/CronNightlyJob.kt 61 lines · 27 code · 29 comments · 5 blank
Scheduled component that runs nightly (configurable via projectforge.cron.nightly property). Executes Hibernate Search re-indexing to keep the full-text search index synchronized with the database.

Design

Spring Boot @Component with a @Scheduled cron trigger. On execution, spawns a new Thread (not a Kotlin coroutine) to run HibernateSearchReindexer.execute() asynchronously. Logs start/finish with millisecond duration formatting. Error handling catches Throwable to ensure the scheduler is never blocked by a failed re-index.

Design Decision: Thread vs Coroutine

The original implementation used Kotlin coroutines but was changed to plain Thread (commit 1a77630dc) for simplicity and to avoid coroutine scope management within Spring's scheduler context.

Git History

868d6abb7 2025 -> 2026
1a77630dc Kotlin.Coroutine -> Thread in Cronjobs and SystemService
63081666f Source file headers: 2024-> 2025.
619985f48 Release 8.1 snapshot (#247)
92a1b6185 WIP: OrderbookSnapshot. WIP: Sanity cron job, Schedulers using now Coroutines.
9013a5208 Migration stuff in progress...
b6092df09 Copyright 2023 -> 2024
ab45d51fa Copyright 2001-2022 -> 2001-2023.
f1a12e2e5 MEB functionality and SmsReceiverServlet removed.
5f7ef41b8 Copyright 2021 -> 2022
ceb63e8a1 Source code header: (C) 2001-2021.
eec34d117 Jcr backup as own Job
82d709614 Jackrabbit OAK successfully integrated.
839d72b2d Jackrabbit integration into ProjectForge app failed!