As mentioned in
The idea of the post commit listener is to run just after the transaction and wait for completion with a short timeout.
The listener must implement PostCommitEventListener and be marked as async="false". It is then handled by the PostCommitEventExecutor (if marked as async="true", it is handled by an asynchronous call instead).
Instead of using the WorkManager, the post commit listener is executed in a dedicated thread pool and the transaction thread waits for completion (at least 300ms) before returning. This enables to do some processing after the transaction and before returning the HTTP response.
To mitigate the randomness (sometimes 0.3s is not enough), the timeout is set to 1min when running tests.
Post commit listeners are too complex and inefficient:
- They use a dedicated large thread pool that can create up to 100 threads.
- There is an overhead to reconnect events and session.
- Under peak, it participates to collapse the platform by using more threads, transactions and connections
- The "pseudo realtime" behavior is random depending on the time the main thread waits for a reply, this can create complex bugs.
Nothing prevents to do the same "pseudo realtime" behavior using directly the afterCompletion, this is already done for the Elasticsearch indexing.
After having removed all the post commit listeners with
NXP-26911, let's deprecate the code related to the PostCommitEventExecutor.