Class BackgroundJobService
java.lang.Object
com.atlassian.confluence.impl.backgroundjob.BackgroundJobService
The service that allows to add new background tasks.
- Since:
- 8.1.0
-
Constructor Summary
ConstructorsConstructorDescriptionBackgroundJobService(BackgroundJobDAO backgroundJobDAO, org.springframework.transaction.PlatformTransactionManager transactionManager, com.atlassian.event.api.EventPublisher eventPublisher) -
Method Summary
Modifier and TypeMethodDescriptionAdds a new background job.convertToHashMap(String customerInfoJSON) convertToJson(Map<String, Object> map) intProcess a next portion of active jobs.voidregisterBackgroundJobProcessor(BackgroundJobProcessor backgroundJobProcessor) Registers a background processor.voidrunJobSynchronously(Class<?> processorClass, Map<String, Object> parameters) Starts the job synchronously.voidunregisterBackgroundJobProcessor(BackgroundJobProcessor backgroundJobProcessor) Unregisters a background processor.
-
Constructor Details
-
BackgroundJobService
public BackgroundJobService(BackgroundJobDAO backgroundJobDAO, org.springframework.transaction.PlatformTransactionManager transactionManager, com.atlassian.event.api.EventPublisher eventPublisher)
-
-
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
-