Scheduler(Cron) Mechanism
SORMAS uses the J2EE (Jakarta EE) timer service to schedule and execute recurring background tasks.
The scheduler is configured using the @Schedule
annotation on methods within singleton EJBs (Enterprise Java Beans).
Each annotation specifies the interval (hour, minute, second) at which the method should be invoked by the application server. This mechanism ensures that maintenance and data processing tasks are performed automatically and reliably, without manual intervention or external cron jobs. Each job is executed automatically at a specific interval to perform routine maintenance, data processing, or synchronization tasks essential for the operation of the system.
The configuration is managed within the application code, making it easy to maintain and update scheduling logic as needed.
Cron Intervals
SORMAS EJB scheduler are configured with @Schedule annotations in a central singleton EJB (CronService
class). The following is a list of the default scheduler intervals and their corresponding methods:
Every 10 minutes:
sendNewAndDueTaskMessages
Sends notifications for new and due tasks to users by callingTaskFacade.sendNewAndDueTaskMessages()
. Ensures users are informed about tasks updates.Every 2 minutes:
calculateCaseCompletion
Updates the completeness status of all cases by callingCaseFacade.updateCompleteness()
. This helps maintain accurate tracking of case data and completeness.Every hour (minute 0):
fetchExternalMessages
If the external messages feature is enabled, fetches and saves external messages usingExternalMessageFacade.fetchAndSaveExternalMessages(null)
. Triggers the procession of external messages.Daily at 01:00:
deleteAllExpiredFeatureConfigurations
Deletes feature configurations whose end dates have been reached by callingFeatureConfigurationFacade.deleteAllExpiredFeatureConfigurations(new Date())
. Keeps the system configuration up to date and removes obsolete feature settings.Daily at 01:05:
generateAutomaticTasks
Generates automatic tasks for contact follow-up and weekly report submission if the respective features are enabled. UsesContactFacade.generateContactFollowUpTasks()
andWeeklyReportFacade.generateSubmitWeeklyReportTasks()
.Daily at 01:10:
cleanUpTemporaryFiles
Deletes temporary export files older than 2 hours from the export folder. Iterates through files in the temp directory and removes those matching the SORMAS temp file prefix and age criteria.Daily at 01:15:
archiveCases
Archives cases that are eligible based on the configured threshold. UsesCaseFacade.archiveAllArchivableCases(daysAfterCaseGetsArchived)
. Also checks and warns if the case archiving threshold is less than the contact archiving threshold.Daily at 01:20:
archiveEvents
Archives events that are eligible based on the configured threshold. UsesEventFacade.archiveAllArchivableEvents(daysAfterEventsGetsArchived)
. Also checks and warns if the event archiving threshold is less than the event participant archiving threshold.Daily at 01:25:
cleanupDeletedDocuments
Cleans up documents that have been marked as deleted by callingDocumentFacade.cleanupDeletedDocuments()
.Daily at 01:30:
deleteSystemEvents
Deletes system events that are older than the configured threshold usingSystemEventFacade.deleteAllDeletableSystemEvents(daysAfterSystemEventGetsDeleted)
. Helps keep the event log manageable.Daily at 01:40:
updateImmunizationStatuses
If the immunization status automation feature is enabled, updates immunization statuses by callingImmunizationFacade.updateImmunizationStatuses()
.Daily at 01:50:
syncInfraWithCentral
Synchronizes infrastructure data with the central server usingCentralInfraSyncFacade.syncAll()
. Keeps local and central infrastructure data consistent.Daily at 01:55:
deleteExpiredEntities
Deletes expired core entities according to automatic deletion rules by callingCoreEntityDeletionService.executeAutomaticDeletion()
. Maintains data retention compliance.Daily at 02:15:
archiveContacts
Archives contacts that are eligible based on the configured threshold usingContactFacade.archiveAllArchivableContacts(daysAfterContactsGetsArchived)
.Daily at 02:20:
archiveEventParticipants
Archives event participants that are eligible based on the configured threshold usingEventParticipantFacade.archiveAllArchivableEventParticipants(daysAfterEventParticipantGetsArchived)
.Daily at 02:25:
archiveImmunizations
Archives immunizations that are eligible based on the configured threshold usingImmunizationFacade.archiveAllArchivableImmunizations(daysAfterImmunizationsGetsArchived)
.Daily at 02:30:
archiveTravelEntry
Archives travel entries that are eligible based on the configured threshold usingTravelEntryFacade.archiveAllArchivableTravelEntries(daysAfterTravelEntryGetsArchived)
.Daily at 02:30:
deleteExpiredSpecialCaseAccesses
Deletes expired special case access permissions by callingSpecialCaseAccessFacade.deleteExpiredSpecialCaseAccesses()
.Daily at 02:35:
syncUsersFromAuthenticationProvider
If user sync is enabled and the feature is active, synchronizes users from the authentication provider usingUserFacade.syncUsersFromAuthenticationProvider()
.Daily at 02:40:
deleteOldNegativeSamples
Deletes old negative samples according to the configured rules by callingSampleService.cleanupOldCovidSamples()