使用骆驼2.13.2.在我解决问题时,请耐心等待:
我有一个子进程,我需要跟踪飞行中的订单。主进程使用一个长事务,在一些冗长的验证结束时保留订单信息。如果两个具有相同密钥的订单相隔子秒提交,挂起的订单验证可能不会标记最后一个订单。因此,我有一个路由,它使用带有PROPIGATION_REQIRES_NEW的新事务来保留飞行中的信息,以补充挂起的订单验证,直到相关订单信息被提交:
<route id="insertInflightRoute">
<from uri="direct-vm:insertInflightEndpoint"/>
<transacted ref="PROPAGATION_REQUIRES_NEW" />
<代码>
<bean ref="inflightService" method="setInflightException"/>
</onException>
<!-- DB insert via Mybatis autowired in bean. Working fine-->
<bean ref="inflightService" method="insert"/>
</route>
当第二个订单尝试插入到这个飞行表中时,一旦事务尝试提交,就会引发PK违规异常。这也工作正常。
我的问题是路由级别
我想指出的是,路由级别的< code >
如果您希望路由级别onException改变原始的交换/消息,您需要设置它来处理它,例如handled=true,然后在bean中您可以在交换上设置一个新的异常,或者抛出一个异常。
我有一个解决我的问题的变通办法,虽然不是我想的那么理想。
我回到呼叫路由并封装了
<doTry>
<!-- insert into inflight mdn table immediately -->
<to uri="direct-vm:insertInflightEndpoint"/>
<doCatch>
<exception>java.sql.SQLException</exception>
<bean ref="inflightService" method="setInflightException"/>
</doCatch>
</doTry>