I set up the job to be triggered daily and is not happening, I cannot see any on the logs that could be causing this issue, months ago we have the same job consumer working properly on AEM Cloud but now after we enable it I can see the job is set to trigger but the consumer is not happening any time
Scheduling job : midnight/job/categories, hour 0 minute 10
@Component(service=JobConsumer.class,
immediate = true,
property= {
JobConsumer.PROPERTY_TOPICS + "=midnight/job/categories"
})
public class CategoriesConsumer implements JobConsumer {
{ "topic": "midnight/job/categories", "instances": [ "33f32c32-5bd5-4fcb-b2a2------------", "local" ] },
I can see the job has an instance assigned but on crx
So no idea why the consumer is not being triggered
Additional the scheduler is happening as I can see the logs
Collection<ScheduledJobInfo> myJobs = jobManager.getScheduledJobs(TOPIC, 1, null);
log.info("Scheduler {} is enable {}",TOPIC,config.enabled());
if (myJobs.isEmpty()) {
// daily invocation not yet scheduled
log.info("Scheduling job : {}, hour {} minute {}", TOPIC, config.hour(),config.minute());
JobBuilder.ScheduleBuilder scheduleBuilder = jobManager.createJob(TOPIC).schedule();
scheduleBuilder.hourly(config.minute());
if (scheduleBuilder.add() == null) {
// something went wrong here, use scheduleBuilder.add(List<String>) instead to get further information about the error
log.debug("failed to add scheduler : {}, daily {} {}", TOPIC, config.hour(),config.minute());
}
}
Regards
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi Everyone the issue was related to the parameters sent to the job I was not sending anything to the job so is not being executed
Map<String,Object> params = new HashMap<>();
SimpleDateFormat sdf = new SimpleDateFormat("dd-M-yyyy hh:mm:ss");
String date = sdf.format(Calendar.getInstance().getTime());
params.put("date", date);
jobManager.addJob(TOPIC,params);
After adding some parameters to the job topic the jobs being executed
Hi @jonsan191086 ,
Can you give a bit more details about the
use case & are you using any schedulers to do so.?
The scheduler is calling an external endpoint to create/update data (Content Fragments and Pages if required)
Hey @jonsan191086 , Scheduler seems fine, try Job Consumer class option i gave above.
Hi @jonathan-sanchez-publicis ,
Attaching below useful for reference. Hope this will help.
https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/trouble-setting-up-a-sling...
Hey @jonsan191086 ,
I think It's an issue with Job Consumer Class, I found some useful code from Old Community Posts.
package com.aem.demoproject.core.listeners;
import org.apache.sling.event.jobs.Job;
import org.apache.sling.event.jobs.JobManager;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Map;
@Component
public class JobComponent {
@Reference
private JobManager jobManager;
public static final String JOB_TOPIC="com/sling/eventing/page/job";
private final Logger LOG = LoggerFactory.getLogger(this.getClass());
@Activate
protected void activate(){
addJob();
}
public void addJob(){
LOG.debug("Inside add job");
Map<String,Object> param = new HashMap<String,Object>();
param.put("eventPath","/content/demo");
Job job = jobManager.addJob(JOB_TOPIC,param);
LOG.info("Job "+job.getTopic()+" is created successfully on "+job.getCreated().getTime());
}
}
JobConsumerImpl.java:
package com.aem.demoproject.core.listeners;
import org.apache.sling.event.jobs.Job;
import org.apache.sling.event.jobs.consumer.JobConsumer;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component(service=JobConsumer.class, immediate = true, property = {JobConsumer.PROPERTY_TOPICS + "=" + JobComponent.JOB_TOPIC})
public class JobConsumerImpl implements JobConsumer {
private final Logger LOG = LoggerFactory.getLogger(this.getClass());
@Override
public JobResult process(Job job) {
LOG.info("Inside job process method");
String eventPath = (String) job.getProperty("eventPath");
LOG.info("Event path={}", eventPath);
return JobResult.OK; // Return based on actual implementation logic.
}
}
Hope this helps,
Aditya Chabuku
I have a consumer just for a test and the same case here never happens on the cloud if I tried on my local works fine
@Component(service= JobConsumer.class,
immediate = true,
property= {
JobConsumer.PROPERTY_TOPICS + "=testing/job/jhon"
})
public class TestingConsumer implements JobConsumer {
private static final Logger log = LoggerFactory.getLogger(TestingConsumer.class);
public JobResult process(final Job job){
log.info("Testing Scheduler Consumer is now running");
log.info("Time {}", Calendar.getInstance().getTime());
return JobResult.OK;
}
}
Also, I found some logs that maybe are related, as this is a cloud I'm not able to see if the bundle is being affected or how is this being affecting others bundles
[{"name": "All bundles are up", "pid": "org.apache.felix.hc.generalchecks.BundlesStartedCheck~systemready", "message": ["TEMPORARILY_UNAVAILABLE Inactive bundle 0 org.apache.felix.framework: STARTING, "INFO --- unsatisfied ref jobManager interface org.apache.sling.event.jobs.JobManager ","INFO --- Component org.apache.sling.event.impl.jobs.JobManagerImpl satisfied","INFO --- unsatisfied ref workflowBucketManager interface com.adobe.granite.workflow.core.jcr.WorkflowBucketManager ",
Hi @jonsan191086,
Can you please check whether the job topic is added under the "Apache Sling queue configuration".
This is all I have access to on Cloud, sadly I cannot see the bundles or configurations as we see on previous versions of AEM
I can see here there are no scheduled jobs but on local, I can see nodes on that node
Can you please check the "Apache Sling queue Configuration" as I mentioned earlier? under configurations.
As I told you I don't have access to see that way the configurations only as json format and there is any called that way on AEM Cloud
In AEM as a Cloud service, we can see the configurations or bundles either in text or in JSON. you need to search with the PID of the configurations. if you are unable to find the configuration you need to configure that and deploy to the instance.
Hi,
I have a job consumer with a topic.
Do not see it in "Apache Sling Job Queue Configuration". and also not seeing code getting executed in the job consumer process method.
Does topic needs to be added manually ?
Thanks,
sri
Views
Replies
Total Likes
Hi Everyone the issue was related to the parameters sent to the job I was not sending anything to the job so is not being executed
Map<String,Object> params = new HashMap<>();
SimpleDateFormat sdf = new SimpleDateFormat("dd-M-yyyy hh:mm:ss");
String date = sdf.format(Calendar.getInstance().getTime());
params.put("date", date);
jobManager.addJob(TOPIC,params);
After adding some parameters to the job topic the jobs being executed
Views
Likes
Replies
Views
Likes
Replies