简体   繁体   English

如何重试将Java Spring Flow转换为Spring Integration Work Flow?

[英]How to convert Java Spring Flow to Spring Integration Work Flow with retry?

I have a quite simple method within a Spring component class 我在Spring组件类中有一个非常简单的方法

@Service("wsOrderCreationService")
public class WsOrderCreationServiceImpl implements WsOrderCreationService {
...
public void saveLedger(SdiOrderSkuLedger orderSkuLedger)    {
    sdiOrderSkuLedgerService.save(orderSkuLedger);
}

I would like to apply retry to this method but I cannot use spring-retry 1.1.12 because my core Spring version is 3.0 and lower versions of spring-retry do not allow XML configuration. 我想将重试应用于此方法,但是我不能使用spring-retry 1.1.12,因为我的核心Spring版本是3.0,而spring-retry的较低版本不允许XML配置。 We are successfully using Spring Integration with retry in this application, so I am thinking of converting this method to SI workflow. 我们已在此应用程序中成功地将Spring Integration与retry一起使用,因此我正在考虑将此方法转换为SI工作流。 What is the best way to do this conversion? 进行此转换的最佳方法是什么?

Let me guess that you can use RequestHandlerRetryAdvice in the <request-handler-advice-chain> for the <service-activator> . 让我猜想您可以对<service-activator>使用<request-handler-advice-chain>中的RequestHandlerRetryAdvice

From other side you can build something like <gateway> for some service-interface and use that interface in some your service as an Integration front-end. 另一方面,您可以为某些service-interface构建类似<gateway>东西,并将该接口在某些服务中用作Integration前端。

So, what you need for your purpose is a <gateway> which sends message to the <service-activator> with the RequestHandlerRetryAdvice for some service method which requires the retry logic. 因此,您需要的是<gateway> ,它使用RequestHandlerRetryAdvice将消息发送到<service-activator> ,以获取某些需要重试逻辑的服务方法。

That's how to answer to your particular question. 这就是如何回答您的特定问题。

From other side the Spring Retry framework isn't designed for the the XML config because it is enough straightforward just for the regular <bean> definition. 另一方面,Spring Retry框架不是为XML配置设计的,因为它对于常规的<bean>定义来说已经足够简单了。 You should just configure RetryOperationsInterceptor (and its dependencies) via standard Spring AOP Framework. 您应该只通过标准Spring AOP Framework配置RetryOperationsInterceptor (及其依赖项)。

From there you don't need to introduce the Spring Integration layer just for the simple retry around one service. 从那里开始,您不必为了简单地重试一项服务而引入Spring Integration层。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM