0

I've been attempting to make my Spring application use Spring Retry for the past few days with no luck so far. I have an XML based config so I've tried adding

<context:annotation-config/>
<aop:aspectj-autoproxy />
<bean class="org.springframework.retry.annotation.RetryConfiguration" />

along with adding the needed dependencies and setting the function I'm using @Retryable, this didn't work.

I've also added a component-scan in my XML for a newly created config file, to which I've added @Configuration and @EnableRetry. I've tried this both with an empty config file and one with a ReturnPolicy set up in it, tried both of these setups with and without Aspects instead of using @Retryable. Neither options worked.

I'm running out of sources and ideas to explore, any help would be greatly appreciated.

Thanks!

M. Deinum
  • 115,695
  • 22
  • 220
  • 224

1 Answers1

0

I hope you are setting and calling it correctly. The @Retryable annotation on the method to be discovered needs to be called correctly from an initialised spring context. Are you doing that( method invoked from a bean from the spring context) or called by other means - outside context?

Alternatively JUnit is best friend - try SpringJunit4ClassRunner

You should restructure your test class at least to something like:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes=MyConfig.class)
public class MyServiceTest {
    @Configuration
    @EnableRetry
    @Import(myService.class)
    public static class MyConfig {}

Couple of reference pages are here

Sheetal Mohan Sharma
  • 2,908
  • 1
  • 23
  • 24
  • I'm calling the method from a Controller annotated class in the same context, the retryable function is in a Service class. They're both in the same project and are scanned in my applicationContext.xml – CreativeUserName12 Jul 03 '18 at 07:57