Class BackgroundJobService
- Since:
- 8.1.0
-
Constructor Summary
ConstructorsConstructorDescriptionBackgroundJobService
(BackgroundJobDAO backgroundJobDAO, org.springframework.transaction.PlatformTransactionManager transactionManager) -
Method Summary
Modifier and TypeMethodDescriptionAdds a new background job.convertToHashMap
(String customerInfoJSON) convertToJson
(Map<String, Object> map) int
Process a next portion of active jobs.void
registerBackgroundJobProcessor
(BackgroundJobProcessor backgroundJobProcessor) Registers a background processor.void
runJobSynchronously
(Class<?> processorClass, Map<String, Object> parameters) Starts the job synchronously.void
unregisterBackgroundJobProcessor
(BackgroundJobProcessor backgroundJobProcessor) Unregisters a background processor.
-
Constructor Details
-
BackgroundJobService
public BackgroundJobService(BackgroundJobDAO backgroundJobDAO, org.springframework.transaction.PlatformTransactionManager transactionManager)
-
-
Method Details
-
addJob
public Long addJob(Class<?> processorClass, Map<String, Object> parameters, String description, Instant runAt) Adds a new background job.- Parameters:
processorClass
- processor's classparameters
- job parametersrunAt
- desired execution time (or Instant.now if it has to be run immediately)- Returns:
- job id
-
runJobSynchronously
Starts the job synchronously. It uses the same processor used in addJob, calls the job again and again until the job finishes. It is not recommended for production, it should be mostly used in tests.
No background job records created in the database; it does not support delayed execution.
Note: the job will be terminated if it takes more than SYNC_EXECUTION_TIMEOUT_SEC
- Parameters:
processorClass
- processor's classparameters
- job parameters- Since:
- 9.1.0
-
processNextJobs
@Internal public int processNextJobs()Process a next portion of active jobs. -
registerBackgroundJobProcessor
Registers a background processor. -
unregisterBackgroundJobProcessor
Unregisters a background processor. -
convertToJson
-
convertToHashMap
-