I have a service like so:
@Service
@Transactional
public myService{
public Flux<entity1> method1(){
// some non flux code
return Flux.interval().filter().doFinally(MyResponse myRes-> updateDataSource(entity1));
}
public void updateDataSource(entity1){
MyRepo.save(entity1);
// code that can throw some exceptions
MyRepo.save(entity2);
}
}
I have a service class annotated with @Transactional. I have a method1() which returns a flux and calls another service method updateDataSource which persists an entity into the DB runs some code that can throw exception and persists a second entity.
My problem is that after persisting entity1 in updateDataSource if an exception is thrown the saved entity1 is not rolled back. In the call stack I cannot see any Transaction manager related proxies/ interceptors even though I'm calling a method which is inside a @Transactional service.
Why is the @Transactional annotation not working with updateDataSource ?