Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring integration 如何为spring集成流添加try-catch异常以实现嵌套事务_Spring Integration_Spring Integration Dsl - Fatal编程技术网

Spring integration 如何为spring集成流添加try-catch异常以实现嵌套事务

Spring integration 如何为spring集成流添加try-catch异常以实现嵌套事务,spring-integration,spring-integration-dsl,Spring Integration,Spring Integration Dsl,如何在spring集成流中处理嵌套事务。基本上,我有一个从数据库中获取所有订单的流程,并按订单进行处理,在单个订单上抛出异常的情况下,所有处理的订单都会回滚 IntegrationFlows.from("perOrder") .filter(Order.class, order -> order.getItems().size() > 0) .handle(orderHandler, "handle") /*someway i way wa

如何在spring集成流中处理嵌套事务。基本上,我有一个从数据库中获取所有订单的流程,并按订单进行处理,在单个订单上抛出异常的情况下,所有处理的订单都会回滚

    IntegrationFlows.from("perOrder")
         .filter(Order.class, order -> order.getItems().size() > 0)
         .handle(orderHandler, "handle") /*someway i way want to add try/catch for this method here so that 
if handle method throws exception, want to suppress for that order and mark as failure only for that order */
         .get();

public class OrderHandler {
   @Transactional(propagation = Propagation.NESTED)
   public handle() {
      processing code 
      throw exception in case of any validation failure
   }
}

为此,我们提供了一个adviceChain,该adviceChain将注入该
句柄()的端点中:

.handle((GenericHandler)(p,h)->{
抛出新的RuntimeException(“故意”);
},e->e.advice(retryAdvice())
您可以在那里插入任何可用的
建议
实现:,包括
TransactionInterceptor


使用try…catch语义的最好方法是使用
表达式evaluationRequestHandlerAdvice
。在文档和JavaDocs中查看它的描述。

谢谢,我将尝试上面提到的选项
.handle((GenericHandler<?>) (p, h) -> {
                    throw new RuntimeException("intentional");
                }, e -> e.advice(retryAdvice()))