Monday, April 21, 2014

How to use sling thread pool in CQ/AEM

Use Case: You are designing an application where you might need to delegate Job to a separate thread and you want to control this using thread pool so that your application it self does not run out of threads.

Prerequisite: Knowledge of Java Threads and basic Knowledge of thread pool. Note that there are Java Level thread pool as well that you can use. Check http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/package-summary.html for that.

Reference: https://sling.apache.org/documentation/bundles/apache-sling-commons-thread-pool.html

Implementation Example:

Step 1: Create your Thread class

public YourThreadClass implements Runnable {


 public void run() {
    //Your custom logic
}
}

Step 2: Main class to use sling Thread pool


Use CQ dependency finder to find what dependency you need for above code in your pom.xml

10 comments:

  1. Nice use case. We will promote this from with Adobe.

    ReplyDelete
  2. Thanks for this great share. This site is a fantastic resource. Keep up the great work here at Sprint Connection! Many thanks.

    Southbay Pool Cleaning Services

    ReplyDelete
  3. Char Dham Yatra
    At tourtraveltourism.com you can do chardham yatra from any of the city in India. We have detail about all of the cities. You can select from which city you want to do the Yatra. You can email us or you can just give a miss call to us 07351064829.
    Char Dham Yatra from Haridwar
    Char Dham Yatra Packages from Haridwar
    Char Dham Yatra Tour Package from Haridwar

    ReplyDelete
  4. If your tour plan consists of 2 days in Shimla and 3 days in Manali, it might be cost efficient to hire a taxi for the whole trip than to travel by local taxi for sightseeing.
    Taxi from Delhi to Manali
    Delhi to Manali Taxi
    Taxi from Delhi Airport to Manali
    One way Taxi Fare from Delhi to Manali
    Taxi fare from Delhi Airport to Manali

    ReplyDelete