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

How to write a Async job that shows on Jobs console?

Avatar

Level 3

I am writing a long-running job that is expected to be intensive and long-running. The Asynchronous Operations looks promising and the Jobs console is nice similar to workflow console, showing job status, logs etc. 

 

How to write a new custom async job? Am able to create sling job, stores into /var, but it is NOT showing in Jobs console. How to get the custom jobs show under Tools --> General --> Jobs console?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

In order to see your custom job under Tools --> General --> Jobs console, you've to write a new class implementing 

AsyncOperationConfigProviderService

separate from the actual sling async job implementation. 

 

This Servlet renders jobs data in console - 

AsyncJobsDataSourceServlet

which displays the jobs that are implementing AsyncOperationConfigProviderService. For reference, please check the following component services in OSGi console (/system/console/components) 

  • com.adobe.granite.jobs.async.ui.commons.AsyncJobsDataSourceServlet
  • com.day.cq.dam.asset.sourcing.impl.async.AsyncAssetImportConfigProviderService

 

One thing I could not confirm is that uber-jar or aem-sdk-api(for cloud service) exposes the AsyncOperationConfigProviderService for custom implementation. 

View solution in original post

4 Replies

Avatar

Community Advisor

Hi @saravana_sgws 

 

Looks like Async APIs are Adobe internal APIs and you can not use same. I used Java Decompiler to check how Async jobs are created. This is the class Adobe has used to extend to write Async Job : 

com.adobe.granite.jobs.async.commons.AbstractAsyncJobExecutor

But there is not much information of same online. 

If you want to see the status of Sling jobs, you can go to /system/console/slingevent and search for the topic you used to create a job. It will show you the count of failed/completed jobs. For example 

sachinarora_0-1665977722409.png

 

 

 

Avatar

Level 3

Thanks Sachin. Yeah, I too am decompiling, duplicating the code and trying to make it work. Just the Jobs console looks better than felix, shows logs, can add interested properties. Was wondering if anyone had already managed to write a custom async job successfully. 

Avatar

Employee

Hi @saravana_sgws  were you able to achieve the above custom job in the job console. we are also looking for the same? I have created a sling job and storing csv into the var folder.

 

can you please share how did you achieve the same in detail? I couldn't find anything in online.

 

The mentioned package

AsyncOperationConfigProviderService

is not coming in aem sdk or uber jar.

Which dependency needs to be added for this?

Avatar

Correct answer by
Community Advisor

In order to see your custom job under Tools --> General --> Jobs console, you've to write a new class implementing 

AsyncOperationConfigProviderService

separate from the actual sling async job implementation. 

 

This Servlet renders jobs data in console - 

AsyncJobsDataSourceServlet

which displays the jobs that are implementing AsyncOperationConfigProviderService. For reference, please check the following component services in OSGi console (/system/console/components) 

  • com.adobe.granite.jobs.async.ui.commons.AsyncJobsDataSourceServlet
  • com.day.cq.dam.asset.sourcing.impl.async.AsyncAssetImportConfigProviderService

 

One thing I could not confirm is that uber-jar or aem-sdk-api(for cloud service) exposes the AsyncOperationConfigProviderService for custom implementation.