Loading

How to deal with java.util.concurrent.RejectedExecutionException: ThreadPoolExecutor did not accept within 30000 MILLISECONDS with Batch Jobs

Veröffentlichungsdatum: Jul 22, 2025
Aufgabe

GOAL

This article explains how to deal with the error "java.util.concurrent.RejectedExecutionException: ThreadPoolExecutor did not accept within 30000 MILLISECONDS"  and your batch job stopped processing records. 

Schritte
Usually when you have a batch job that stops processing records and you see the error "java.util.concurrent.RejectedExecutionException: ThreadPoolExecutor did not accept within 30000 MILLISECONDS" means that you are not having enough threads available to process records. 
This often happens when you are setting a batch:threading-profile with an undersized amount of maxThreadsActive, and each record block (which are processed by a thread) are taking enough time to suffer from a thread starvation. 
For example: 
You want to process 2500 records with a batch job configuration as follows :
  • block size= 100
  • maxThreadsActive=10
The batch process will use the 10 thread to process every 100 records, which will turn into 1000 being processed. This leaves you with 1500 records waiting for threads to be available to process them. But if each thread is taking more than 30 seconds to finish, it will lead you to reach the default value of threadWaitTimeout, and the batch dispatcher will give up waiting for a thread to be available to process the remaining 1500 records. 

This can be avoided by changing the threadWaitTimeout to a more suitable timeout to your use case or to threadWaitTimeout="-1"  which will set it to wait forever. 


 
Nummer des Knowledge-Artikels

001114956

 
Laden
Salesforce Help | Article