Date: 2022-09-13
Accepted (lazy consensus).
Implemented.
See description of blocking vs reactive programming odel described in ADR-57.
Sometimes reactive code needs to execute blocking tasks.
Historically James used the elastic scheduler for scheduling such blocking calls. This scheduler starts a thread for each task submitted (and attempt to reuse threads when possible) and results in high thread count.
That is why project reactor deprecated the elastic scheduler in favor of bounded-elastic (similar to a thread pool).
Migrate from elastic scheduler to bounded-elastic scheduler.
We expect a reduction in used threads under load from such a change.
Also, getting rid of elastic scheduler might be a requirement to upgrade to reactor 3.5 upward.
Associated risk:
To prevent such a dead-lock code executed on bounded-elastic should not depend on scheduling nested blocking call on bounded-elastic scheduler for its completion. We can thus avoid such a situation by using a scheduler dedicated by nested blocking calls.
Alternatives to the “blocking call wrapper” scheduler described above includes a full reactive migration for Apache James (ie no blocking calls meaning no nested blocking calls).
While this clearly is the target such a work is not realistically done within a limited time frame. As such we need a transitional model allowing reactive code to inter-operate with legacy blocking James code.