Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Sling job not being processed by custom consumer

Avatar

Level 3

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:

Screen Shot 2018-02-09 at 11.25.46.png

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

1 Accepted Solution

Avatar

Correct answer by
Level 3

It seemed like simply "restarting" AEM fixed it?

Very weird, as it showed no logs, whatsoever.

View solution in original post

6 Replies

Avatar

Correct answer by
Level 3

It seemed like simply "restarting" AEM fixed it?

Very weird, as it showed no logs, whatsoever.

Avatar

Level 2

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

Avatar

Level 10

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

Avatar

Level 3

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

Avatar

Level 1

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.

Avatar

Level 3

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