简体   繁体   中英

How to convert Java Spring Flow to Spring Integration Work Flow with retry?

I have a quite simple method within a Spring component class

@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. We are successfully using Spring Integration with retry in this application, so I am thinking of converting this method to SI workflow. 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> .

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.

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.

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. You should just configure RetryOperationsInterceptor (and its dependencies) via standard Spring AOP Framework.

From there you don't need to introduce the Spring Integration layer just for the simple retry around one service.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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