在我们的项目中,我们需要在 Hazelcast 交易中将PROPAGATION_REQUIRES_NEW
用于PlatformTransactionManager
,但不幸的是, Hazelcast中不支持“嵌套”交易。
问题是,如何使用 Hazelcast 内部API或某些解决方法来实现这一点?
当前,我们对新的Thread
使用丑陋的解决方案,如下所示:
//We have existing Hazelcast transaction here
Thread t = new Thread(() -> {
//within separate Thread we will have new Hazelcast transaction context here.
});
t.start();
//wait here while Thread will complete execution
t.join();
这种方法行得通,但也许还有另一种方法会更可接受?