eventuate-tram / eventuate-tram-core

Transactional messaging for microservices
Other
1.05k stars 186 forks source link

Return Command with 'withFailure' throw org.springframework.transaction.UnexpectedRollbackException #135

Open brokenbrains opened 3 years ago

brokenbrains commented 3 years ago

Hi dev,

Any idea why onFailure on Command Return throw org.springframework.transaction.UnexpectedRollbackException?

public Message debit(CommandMessage<DebitCommand> cm) { try { accountService.debit(cm.getCommand().getAccountId(), cm.getCommand().getAmount()); return withSuccess(); } catch (InsufficientFundsException e) { logger.info("InsufficientFundsException catch"); return withFailure(new InsufficientFundsReply()); } }

it throw when return withFailure. withSuccess was no problems

here the log tram jdbc error rollback.txt

isfong commented 3 years ago

Hi it's this? code invoked by message handlers shouldn't use Spring's @Transactional since that interferes with Eventuate Tram's transaction management. The stack trace suggests that @Transactional is being used.

cer commented 3 years ago

Sorry for the delayed response.

Hi it's this? code invoked by message handlers shouldn't use Spring's @Transactional since that interferes with Eventuate Tram's transaction management. The stack trace suggests that @Transactional is being used.

Yes, what you are seeing is consistent with having used @Transactional