My Service Class.
@Service
@Transactional(value = "transactionManager", readOnly = true, propagation = Propagation.REQUIRED)
public class DeviceServiceImpl{
@Transactional(readOnly = false)
public void blockAllDevices(){
createSmsDeviceBlock();
}
public void createSmsDeviceBlock(){
addToLogTables();
smsService.sendSms();
}
@Transactional(readOnly = false,propagation = Propagation.REQUIRES_NEW)
public void addToLogTables(){
try {
//save object with DAO methods...
} catch (Exception e) {
throw new ServiceException(ServiceException.PROCESSING_FAILED, e.getMessage(), e);
}
}
}
From my controller , service method blockAllDevices() getting called. addToLogTables() method is marked as Propergation.REQUIRED_NEW, but the problem is with the addToLogTables() method new transaction not getting created and existing transaction is using.
The thing i want to do is, the transaction on addToLogTables() method should be commit before execute smsService.sendSms() method.
My problem here, if transaction failed to commit , on method addToLogTables() method, it should not execute smsService.sendSms() method.