Not able to view JobStatus of completed jobs.
Tried these steps but not working:
jobManager.getJobById(jobId)
jobManager.findJobs(JobManager.QueryType.ALL, TEST_JOB_TOPIC, -1);
This returns only the failed or GIVEN_UP status ones
jobManager.findJobs(JobManager.QueryType.HISTORY, TEST_JOB_TOPIC, -1)
AEM version AEM 6.5.15
Solved! Go to Solution.
Views
Replies
Total Likes
From what I hear, as JobManager currently DOES NOT retain any completed jobs the workaround is we store the job and use it for retrieval. Thanks
Can you please try with following code?
Collection<Job> succeededJobs = jobManager.findJobs(JobManager.QueryType.SUCCEEDED, topic, 100, (Map<String, Object>[]) null);
Still the same null. Although I have succeeded jobs, the only QueryType value that gives values is GIVEN_UP. Is it because the current jobmanager configuration does not keep track of the completed jobs but only keeps track of the GIVEN_UP(retried ones) ? If so could you please guide me with any configuration change that would be required.
Hi @samaraneni IMO, you can try out using the API i.e. TopicStatistics.
Reference - https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/org/apache/sling/even...
This has the method i.e. getNumberOfProcessedJobs() to get the no of processed jobs for a particular job topic.
Hope this helps!
Thanks
Hi, the use case is, I'm writing a status monitoring servlet endpoint which takes in a list of jobIds that belong to a topic and returns the status of each. Some of these could be failed and some succeeded. I have hard time finding the status of completed ones, only the failed with the status of GIVEN_UP are available to view. So to achieve this I think getNumberOfProcessedJobs() won't help. Please guide me here
Hi @samaraneni
In AEM 6.5, the JobManager API primarily focuses on ongoing or failed jobs, and completed jobs are often not retained for direct querying through the JobManager.
If you specifically need to capture the status of completed jobs, one option is to implement a custom solution:
Custom JobProcessor: In your JobProcessor implementation, after successfully processing the job, log the relevant details or store them in a custom location.
void process(Job job) {
try {
// Your job processing logic
// Log successful completion
log.info("Job {} completed successfully", job.getId());
// Store job details or status in a custom location
storeJobDetails(job);
} catch (Exception e) {
// Log failure
log.error("Job {} failed: {}", job.getId(), e.getMessage(), e);
}
}
Custom Storage for Job Details: Implement a custom mechanism to store job details or status in a dedicated node in the repository, database, or external storage.
void storeJobDetails(Job job) {
// Implement logic to store job details, e.g., in a custom node in the repository
}
Retrieve Status Programmatically: When you need to retrieve the status of a completed job, query your custom storage instead of relying solely on the JobManager.
String jobStatus = retrieveJobStatus(jobId);
Implement the retrieveJobStatus method to query your custom storage for the status of a specific job ID.
Hope this information is going to help you !
@samaraneni Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.
Views
Replies
Total Likes
From what I hear, as JobManager currently DOES NOT retain any completed jobs the workaround is we store the job and use it for retrieval. Thanks
Views
Likes
Replies
Views
Likes
Replies