Allow TransactionOutboxImpl#scheduler and ExecutorSubmitter#executor programmatic shutdown#687
Allow TransactionOutboxImpl#scheduler and ExecutorSubmitter#executor programmatic shutdown#687reda-alaoui wants to merge 1 commit intogruelbox:masterfrom
Conversation
8e39a0a to
8b649de
Compare
|
@reda-alaoui I don't understand why the change to Currently it doesn't control the lifetime of the supplied I think the right answer for the |
|
Do you consider like me that the |
|
I don't see why the Any A good rule of thumb is that whatever creates a resource should close it. |
| TimeUnit.MILLISECONDS, | ||
| new ArrayBlockingQueue<Runnable>(16384))); | ||
| return ExecutorSubmitter.builder().build(); | ||
| } |
There was a problem hiding this comment.
@badgerwithagun ExecutorSubmitter does not create an executor, but Submitter does here. AutoCloseable was originally added to Submitter because of this.
There was a problem hiding this comment.
But you don't need to use this method.
You can just create a TransactionOutbox with your own.
var outbox = TransactionOutbox.builder()
.submitter(ExecutorSubmitter.builder().executor(yourExecutor).build())
...
.builder();
This is almost always what you do in a managed environment. The default Submitter implementation uses ForkJoinPool, which is a very bad idea when running in an application container.
Fix #686
Makes
TransactionOutboxandSubmitterimplementAutoCloseable.Please note that if any instance is declared as a Spring bean, Spring will automatically call the close method on shutdown, which is very convenient.