diff --git a/spring-batch-docs/asciidoc/repeat.adoc b/spring-batch-docs/asciidoc/repeat.adoc index 9ed6dc0b1..8c8dfc24c 100644 --- a/spring-batch-docs/asciidoc/repeat.adoc +++ b/spring-batch-docs/asciidoc/repeat.adoc @@ -244,11 +244,16 @@ configure AOP interceptors, see the Spring User Guide): public MyService myService() { ProxyFactory factory = new ProxyFactory(RepeatOperations.class.getClassLoader()); factory.setInterfaces(MyService.class); - factory.setTarget(target); - service = (Service) factory.getProxy(); + factory.setTarget(new MyService()); + + MyService service = (MyService) factory.getProxy(); JdkRegexpMethodPointcut pointcut = new JdkRegexpMethodPointcut(); pointcut.setPatterns(".*processMessage.*"); - ((Advised) service).addAdvice(new DefaultPointcutAdvisor(pointcut, interceptor)); + + RepeatOperationsInterceptor interceptor = new RepeatOperationsInterceptor(); + + ((Advised) service).addAdvisor(new DefaultPointcutAdvisor(pointcut, interceptor)); + return service; } ---- diff --git a/spring-batch-docs/asciidoc/retry.adoc b/spring-batch-docs/asciidoc/retry.adoc index 0b08a2199..ac841e461 100644 --- a/spring-batch-docs/asciidoc/retry.adoc +++ b/spring-batch-docs/asciidoc/retry.adoc @@ -6,6 +6,8 @@ == Retry +include::toggle.adoc[] + To make processing more robust and less prone to failure, it sometimes helps to automatically retry a failed operation in case it might succeed on a subsequent attempt. Errors that are susceptible to intermittent failure @@ -399,13 +401,14 @@ Sometimes, there is some business processing that you know you want `RetryPolicy` in the provided `RepeatTemplate`. -The following example shows a declarative iteration that uses the Spring AOP - namespace to repeat a service call to a method called +[role="xmlContent"] +The following example shows a declarative retry that uses the Spring AOP + namespace to retry a service call to a method called `remoteCall` (for more detail on how to configure AOP interceptors, see the Spring User Guide): -[source, xml] +[source, xml, role="xmlContent"] ---- ---- +[role="javaContent"] +The following example shows a declarative retry that uses java configuration + to retry a service call to a method called + `remoteCall` (for more detail on how to configure + AOP interceptors, see the Spring User Guide): + + +[source, java, role="javaContent"] +---- +@Bean +public MyService myService() { + ProxyFactory factory = new ProxyFactory(RepeatOperations.class.getClassLoader()); + factory.setInterfaces(MyService.class); + factory.setTarget(new MyService()); + + MyService service = (MyService) factory.getProxy(); + JdkRegexpMethodPointcut pointcut = new JdkRegexpMethodPointcut(); + pointcut.setPatterns(".*remoteCall.*"); + + RetryOperationsInterceptor interceptor = new RetryOperationsInterceptor(); + + ((Advised) service).addAdvisor(new DefaultPointcutAdvisor(pointcut, interceptor)); + + return service; +} +---- + The preceding example uses a default `RetryTemplate` inside the interceptor. To change the policies or listeners, you can inject an instance of