Hi,
Is there a way to distinguish between acquired (not not actually running in a job executor thread yet), vs. actually running?
I’m trying to find a way to get the current number of actually running threads per job executor node.
My current approach is to run a SQL query to select counts of rows from ACT_RU_JOB where LOCK_OWNER_ is not null (grouping by LOCK_OWNER_). However, this approach over-counts, as the count it returns is really:
maxJobsPerAcquisition + queueSize + maxPoolSize
(I think I’ve got this formula correct, and I’ve determined it experimentally).
Is there a better way to do this, that just gets number of active? (perhaps via an API).
Thanks!
Galen
Hi Galen,
A tool which may be of interest, in your java/bin folder there may be something called jvisualvm.exe or similar. If you run this, it will give you visual access to the jvm such that yiu can see threads in threadpools, take stack traces etc. It will show you the jvm’s view of whats going on…
regards
Rob
1 Like
Hi Rob,
Thanks, that looks like it will be useful in diagnosing at runtime what is happening.
However, what I’m looking for is a programmatic approach that I can integrate into my web dashboard (Java web application) that will allow me to display the number of currently executing threads.
Thanks,
Galen
Another path you could potentially go down is the JMX route. I believe you are running in Tomcat, and in Tomcat, the job executor threadpool can be managed through JMX. Hence JMX may be a path to an API approach… Failing that, build a custom cockpit plugin which can use the engine’s internals to expose what you want via an API…
R
Hi Rob,
Perfect, I think this is what I’m looking for. I already have hooks in my code to access JMX values.
I think what I want to look at is “ActiveCount”, right?
Also, what’s the difference between CompletedTaskCount and TaskCount?
Thanks!
Galen
Hi Galen,
I don’t know what the difference is…Perhaps one of the Camunda devs will answer, or wading through the code will eventually get you an answer…
regards
Rob
The MBean implementation is JmxManagedThreadPool. It basically delegates all calls to java.util.concurrent.ThreadPoolExecutor, where you can find documentation of the values.
Cheers,
Thorben
Thanks, I’ll check that out,
Galen