How to use property from a property file in the @Backoff
annotation for customize delay time?
This attribute takes only a constant as a value.
I try to initialize someProperty
field with constructor injection, but it not helps and IntellijIDEA shows a message: "Attribute value must be a constant".
This code won't compile:
public class SomeClass {
private final long someProperty;
public SomeClass (@Value("${someProperty}") Long someProperty) {
this.someProperty = someProperty;
}
@Retryable(value = RuntimeException.class, maxAttempts = 2,
backoff = @Backoff(delay = someProperty))
public SomeObject getSomeObject() {
return new SomeObject();
}
}
Can I use delayExpression
attribute like this:
@Retryable(value = RuntimeException.class, maxAttempts = 2,
backoff = @Backoff(delayExpression = "${someProperty}"))