Answering my own question for further reference.
Problem
By default GlassFish Batch Runtime uses concurrent/__defaultManagedExecutor
as its executor service.
You can retrieve its properties with:
./asadmin get resources.managed-executor-service.concurrent/\
__defaultManagedExecutorService.*
In my environment I get the following values:
context-info=Classloader,JNDI,Security,WorkArea
context-info-enabled=true
core-pool-size=0
deployment-order=100
enabled=true
hung-after-seconds=0
jndi-name=concurrent/__defaultManagedExecutorService
keep-alive-seconds=60
long-running-tasks=false
maximum-pool-size=2147483647
object-type=system-all
task-queue-capacity=2147483647
thread-lifetime-seconds=0
thread-priority=5
Notice thatmaximum-pool-size=2147483647
, this is a unlimited managed executor.
Solution
Create your own Managed Executor Service.
./asadmin create-managed-executor-service --maximumpoolsize=20 \
--taskqueuecapacity=5000 --longrunningtasks=true concurrent/myJobExecutor
This will limit the pool to 20 concurrent threads. If all threads are currently in use the executor service will queue up to 5000 tasks before rejecting new entries.
Unfortunately the last option(--longrunningtasks=true
) did not work in my environment. This flag is important, it prevents long running tasks to be hung. I had to set the property manually:
./asadmin set resources.managed-executor-service.concurrent/\
myJobExecutor.long-running-tasks=true
Tweak the batch runtime configuration to use your new Managed Exercutor Service (I had to set the datasource as well):
./asadmin set-batch-runtime-configuration --executorservicelookupname \
concurrent/myJobExecutor --datasourcelookupname jdbc/__TimerPool
Fire your jobs and enjoy nice, sane, parallelism.
You can find further information about Configuring the Batch Runtime and Configuring Managed Executor Services in the GlassFish Administration Guide