Sling job not being processed by custom consumer | Community
Skip to main content
Level 3
February 9, 2018
Solved

Sling job not being processed by custom consumer

  • February 9, 2018
  • 5 replies
  • 5608 views

Hello

Currently I have the following situation:

I've made an EventListener that listens for the ReplicationAction.EVENT_TOPIC. To prevent the listener from getting blacklisted, I schedule a sling job in the following way:

String TOPIC = "test/jobHandler";

final Map<String, Object> properties = ImmutableMap.of(

  INDEX_ACTION, "ADD",

   SlingConstants.PROPERTY_PATH, pagePath,

   Job.PROPERTY_JOB_QUEUE_NAME, "test",

   Job.PROPERTY_JOB_TITLE, String.format("Consuming page %s", pagePath)

);

jobManager.addJob(TOPIC, properties);

Now, my consumer is created as following:

@Component(

   immediate = true,
   property = {

  JobConsumer.PROPERTY_TOPICS + "=" + TOPIC
   })

public class JobHandler implements JobConsumer {

@Override
   public JobResult process(final Job job) {

   LOGGER.info("Inside process");

   return JobResult.OK;
   }

}

The weird thing is: the job itself gets added, according to the output of the job manager, but my consumer code never seems to run (I don't see the log statement), except when I deploy my complete application code again to the AEM instance OR when I stop and start my bundle again. Only stopping and starting the component does NOT work!

I've checked /var/eventing and it shows the job in the "assigned" folder, meaning that there has been a consumer that has picked it up, but it never gets finished. If I disable my JobHandler, then the job gets put in the "unassigned" folder, so that indicates that indeed my consumer is picking them up, but not doing anything with them.

If I check the statistics under /system/console/slingevent, then there is no job being added for that specific topic. The queue "test" is also always empty.

The configuration of the queue:

Some logs from the scheduling of the job:

09.02.2018 11:15:50.101 *INFO* [Thread-9] core.publish.scheduler.JobScheduler queue name test

09.02.2018 11:15:50.102 *INFO* [Thread-9] core.publish.scheduler.JobScheduler created instance fa85aace-0d53-46e6-9b93-157d7b76445f

09.02.2018 11:15:50.102 *INFO* [Thread-9] core.publish.scheduler.JobScheduler id 2018/2/9/11/15/fa85aace-0d53-46e6-9b93-157d7b76445f_95

09.02.2018 11:15:50.102 *INFO* [Thread-9] core.publish.scheduler.JobScheduler job state QUEUED

09.02.2018 11:15:50.102 *INFO* [Thread-9] core.publish.scheduler.JobScheduler target instance fa85aace-0d53-46e6-9b93-157d7b76445f

09.02.2018 11:15:50.106 *INFO* [Thread-9] core.publish.scheduler.JobScheduler step count -1

09.02.2018 11:15:50.106 *INFO* [Thread-9] core.publish.scheduler.JobScheduler topic test/JobHandler

Not really sure what the problem here is.

To summarize:

* all components are active

* all of the custom components are active

* jobs are "assigned" but never finished

* jobs get finished after the bundle with the job consumer gets installed/update/package refresh

Environment specs:

Debian Jessie 9

AEM 6.3 SP 1 CFP 2 (6.3.1.2)

OSGi annotations: R6 -> not felix, and please, do not suggest anything with felix annotations

Kind regards

Dylan

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by dylanr46798176

It seemed like simply "restarting" AEM fixed it?

Very weird, as it showed no logs, whatsoever.

5 replies

dylanr46798176AuthorAccepted solution
Level 3
February 9, 2018

It seemed like simply "restarting" AEM fixed it?

Very weird, as it showed no logs, whatsoever.

Level 2
January 23, 2023

What if it's a cloud AEM there is no way to restart the instance?

smacdonald2008
Level 10
February 11, 2018

Sometimes restarting fixes small issues like this. I have seen that before.

yaraslaud208334
Level 2
March 20, 2019

I have the same issue, restart haven't help me. AEM 6.4.3

souvikn
April 10, 2019

I was also having the same problem once - found that we were saving a custom object in the payload which AEM was saving as Binary data on the Sling job's properties. Saving it as a String solved the issue.

yaraslaud208334
Level 2
April 11, 2019

The root cause of the problem that custom objects are prohibited from being deserialized. See more at stackoverflow answer:

aem - Sling job not being processed with custom serializable property - Stack Overflow