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

13 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. Packers and Movers Chennai Give Safe and Reliable ***Household Shifting Services in Chennai with Reasonable ###Packers and Movers Price Quotation. We Provide Household Shifting, Office Relocation, ✔✔✔Local and Domestic Transportation Services, Affordable and Reliable Shifting Service Charges @
    Packers And Movers Chennai

    ReplyDelete
  4. Tatkal Railway Ticket Agent gives you the best cheap rate of railway ticket booking Chandigarh, railway ticket booking Chandigarh, Confirmed Tatkal Ticket Booking Chandigarh Call @ 9999606515.

    Tatkal Rail ticket agent

    train ticket agents in delhi

    confirm train book Chandigarh

    Railway Ticket Booking Agent

    ReplyDelete
  5. Love marriage specialist astrologer Pandit Hari Ram Ji provides a reputable person call @ 7837876237 with the best and authentic services in the love marriage astrology in India.

    Love Problem Solution ####
    Vashikaran Specialist ####
    Love Marriage Specialist ####
    Vashikaran For Love ####
    Vashikaran For Love ####
    Black Magic For Love ####

    ReplyDelete
  6. Ajay Shastri is the best Astrologer canada, he is the most prominent astrologer and Call Now +15875074472 gives accurate prediction about your future.

    Visit Now :-

    Astrologer in toronto ####
    Astrologer in vancouver ####
    Astrologer in ottawa ####
    Astrologer in calgary ####
    Astrologer in edmonton ####
    Astrologer in Montreal ####
    Love problem solution canada ####


    ReplyDelete
  7. Ajay Shastri is the best Astrologer canada, he is the most prominent astrologer and Call Now +15875074472 gives accurate prediction about your future.

    Visit Now :-

    Astrologers in Canada ####
    http://www.astrologerincanada.ca/about-us.html ####
    http://www.astrologerincanada.ca/contact-us.html ####
    Astrologer in Brampton ####
    Astrologer in hamilton ####
    Astrologer in winnipeg ####
    Astrologer in Surrey ####

    ReplyDelete
  8. There will be problems as well. Vashikaran Specialist In Mumbai But it might so Aghori ji happen that problems can be Call Now @ 9517888489.

    Visit Now :-

    Vashikaran specialist in delhi ####
    Vashikaran specialist in mumbai ####
    Vashikaran specialist in pune ####
    Vashikaran specialist in bangalore ####
    Vashikaran specialist in hyderabad ####
    Vashikaran specialist in chennai ####

    ReplyDelete
  9. There will be problems as well. Vashikaran Specialist In Mumbai But it might so Aghori ji happen that problems can be Call Now @ 9517888489.

    Visit Now :-

    Vashikaran specialist in surat ####
    Vashikaran specialist in Vadodara ####
    Vashikaran specialist in kolkata ####
    Vashikaran specialist in chandigarh ####
    Vashikaran specialist in jaipur ####

    ReplyDelete
  10. This ancient practice has not still lost its value and significance Aghori ji has so many uses in people’s life.(Call Now 9517888489).

    Visit Now :-

    Black magic specialist in Delhi ####
    Black magic specialist in pune ####
    Black magic specialist in mumbai ####
    Black magic specialist in Bangalore ####
    Black magic specialist in hyderaBad ####
    Black magic specialist in chennai ####
    Black magic specialist in surat ####

    ReplyDelete