背景
- This application server has “thread canceling” feature. It terminates long-running (20min or more) threads for preventing resource starvation caused by deadlock or infinite loop.
- This application server forbids to make child threads on servlets (this application server can write some logs for failure analysis, but these logs don’t work properly on child threads).
- Some business logics need 30 minutes or more to finish (it is enough for the browsers to get timeout error).
- These logics should be executed only if preceding transaction finished successfully (e.g. the bills should not be printed if payments not recorded to DB successfully).
- I know I can use messaging APIs (e.g. ActiveMQ with JMS API has transactional feature). But I want to avoid these solutions, because a global transaction between RDBMS and JMS will broken in some situations.
问题
我认为我必须在另一个Java上的线程上运行这些逻辑。如何在另一个Java实例上启动线程并异步执行逻辑?
发布于 2018-01-09 15:12:36
经过进一步的调查,我发现Spring集成中的JDBC支持特性涵盖了我的需求。您可以使用出站通道适配器向RDBMS请求异步业务逻辑执行,并在另一个带有入站通道适配器的JVM上运行业务逻辑。
发布于 2017-11-29 07:42:55
我认为您无法在另一个JVM中直接启动线程。由于您没有使用消息队列,所以最好使用RMI来调用不同JVM上的另一个进程上的方法,后者反过来可以为您启动线程。
https://stackoverflow.com/questions/47546795
复制相似问题