How does play handle asynchronous jobs when they are called using the now() method?
Are they executed immediately, or are they stored in a queue and processed by a fixed number of threads? What sort of control do we have over that?
When you call now()
, your job is put into a ScheduledThreadPoolExecutor via submit()
. Since the executor uses a fixed-size pool, your job may end up being queued. Also, the pool is shared with your scheduled jobs , so you may have contention with them in addition to any jobs you spawned on demand.
You can adjust the size of the pool in your application's configuration, using the play.jobs.pool
setting. The default value is 10.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With