We would like for specific methods to configure a different transaction timeout. Example:
@Data
@ConfigurationProperties("app.transactions")
public class TransactionProperties {
private Duration myServiceTransactionTimeout = Duration.ofSeconds(5);
}
and annotate the service with:
@Service
public class MyService {
@Transactional(timeoutString = "#{transactionProperties.myServiceTransactionTimeout.getSeconds()}")
public Response exampleTransaction() {
return doSomethingWithinTransaction();
}
}
Unfortunately, the SpEL seems not to work. It turned out that Spring's AnnotationTransactionAttributeSource is implementing EmbeddedValueResolverAware, but there is no StringValueResolver assigned. Tested with Spring Boot 3.2.0.
Question: What do we need to change so that for methods transaction timeouts are configurable?
As far as we can see, full SpEL is not available here. The requirement can be achieved with an
intinstead of aDurationorPeriodobject:and