Hi,
How to increase the number of threads to run in usage in AEM6.1 through Sling thread pool configuration.
Actually I need to run more than 5 threads concurrently, so I have increased the default MIN_POOL size from 5 to 20. But it is not working.
I have tried also changing in Apache sling job queue configuration and also tried to increase the POOL size by writing a custom service, but it still taking only 5 threads.
Can anyone please help me on this.
Thanks,
Ratna Kumar.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi Ratna
One of my recent read includes the "How to use sling thread pool in AEM".
Link:- http://www.wemblog.com/2014/04/how-to-use-sling-thread-pool-in-cqaem.html (Old article but may be useful).
//
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
I hope this might help you.
Thanks and Regards
Kautuk Sahni
Views
Replies
Total Likes
Hi Ratna
One of my recent read includes the "How to use sling thread pool in AEM".
Link:- http://www.wemblog.com/2014/04/how-to-use-sling-thread-pool-in-cqaem.html (Old article but may be useful).
//
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
I hope this might help you.
Thanks and Regards
Kautuk Sahni
Views
Replies
Total Likes
Hi Kautuk,
I have tried already in the above mentioned perspective by you.
Still have the issue. So if you can give any other solution if possible, that would be great.
Anyway thanks for your fast reply.
Thanks,
Ratna kumar.
Views
Replies
Total Likes
Hi Kautuk,
The issue has been resolved.
We have wrongly configured the POOL_SIZE in service.
Thanks,
Ratna Kumar,
Views
Replies
Total Likes
Please share what you were doing wrong and how it was rectified for communities benefit.
Thanks Ratna in advance.
Thanks and Regards
Kautuk Sahni
Views
Replies
Total Likes
Hi Kautuk,
There is only one minor mistake I have done while configuring the POOL_SIZE. Like for example
@Activate | |
protected final void activate(final Map<Object, Object> config) { | |
this.minThreadPoolSize = OsgiUtil.toInteger(config.get(MINIMUM_THREAD_POOL_SIZE), 5); | |
this.maxThreadPoolSize = OsgiUtil.toInteger(config.get(MAXUIMUM_THREAD_POOL_SIZE), 10); | |
ModifiableThreadPoolConfig threadPoolConfig = new ModifiableThreadPoolConfig(); | |
if(threadPoolConfig.getMinPoolSize()<this.minThreadPoolSize) { | |
threadPoolConfig.setMinPoolSize(this.minThreadPoolSize); | |
} | |
if(threadPoolConfig.getMaxPoolSize()<this.maxThreadPoolSize) { | |
threadPoolConfig.setMaxPoolSize(this.maxThreadPoolSize); | |
} | |
//You can make this configurable as well | |
threadPoolConfig.setPriority(ThreadPriority.NORM); | |
this.threadPool = threadPoolManager.create(threadPoolConfig); | |
if(threadPool == null) { | |
throw new IllegalStateException("Could not get a ThreadPool"); | |
} | |
} |
Here I am calling this.threadPool = threadPoolManager.create(threadPoolConfig) before configuring threadPoolConfig.setPriority(ThreadPriority.NORM);
this.threadPool = threadPoolManager.create(threadPoolConfig);
threadPoolConfig.setPriority(ThreadPriority.NORM);
But it must be
threadPoolConfig.setPriority(ThreadPriority.NORM);
this.threadPool = threadPoolManager.create(threadPoolConfig);
So that is why it is running 5 threads by default.
Thanks,
Ratna Kumar.
Views
Replies
Total Likes
Views
Likes
Replies