in src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java [626:673]
private JobImpl writeJob(final ResourceResolver resolver,
final String jobTopic,
final Map<String, Object> jobProperties,
final QueueInfo info)
throws PersistenceException {
final String jobId = this.configuration.getUniqueId(jobTopic);
final String path = this.configuration.getUniquePath(info.targetId, jobTopic, jobId, jobProperties);
// create properties
final Map<String, Object> properties = new HashMap<>();
if ( jobProperties != null ) {
for(final Map.Entry<String, Object> entry : jobProperties.entrySet() ) {
final String propName = entry.getKey();
if ( !ResourceHelper.ignoreProperty(propName) ) {
properties.put(propName, entry.getValue());
}
}
}
properties.put(ResourceHelper.PROPERTY_JOB_ID, jobId);
properties.put(ResourceHelper.PROPERTY_JOB_TOPIC, jobTopic);
properties.put(Job.PROPERTY_JOB_QUEUE_NAME, info.queueConfiguration.getName());
properties.put(Job.PROPERTY_JOB_RETRY_COUNT, 0);
properties.put(Job.PROPERTY_JOB_RETRIES, info.queueConfiguration.getMaxRetries());
properties.put(Job.PROPERTY_JOB_CREATED, Calendar.getInstance());
properties.put(JobImpl.PROPERTY_JOB_QUEUED, Calendar.getInstance());
properties.put(Job.PROPERTY_JOB_CREATED_INSTANCE, Environment.APPLICATION_ID);
if ( info.targetId != null ) {
properties.put(Job.PROPERTY_JOB_TARGET_INSTANCE, info.targetId);
} else {
properties.remove(Job.PROPERTY_JOB_TARGET_INSTANCE);
}
// create path and resource
properties.put(ResourceResolver.PROPERTY_RESOURCE_TYPE, ResourceHelper.RESOURCE_TYPE_JOB);
if ( logger.isDebugEnabled() ) {
logger.debug("Storing new job {} at {}", Utility.toString(jobTopic, properties), path);
}
ResourceHelper.createAndCommitResource(resolver,
path,
properties);
// update property types - priority, add path and create job
properties.put(JobImpl.PROPERTY_RESOURCE_PATH, path);
return new JobImpl(jobTopic, jobId, properties);
}