protected void doInTransactionWithoutResult(TransactionStatus status) { // wrapper exception to throw if the exchange failed // IMPORTANT: Must be a runtime exception to let Spring regard it as to do "rollback" RuntimeException rce; // and now let process the exchange by the error handler processByErrorHandler(exchange); // after handling and still an exception or marked as rollback only then rollback if (exchange.getException() != null || exchange.isRollbackOnly()) { // wrap exception in transacted exception if (exchange.getException() != null) { rce = ObjectHelper.wrapRuntimeCamelException(exchange.getException()); } else { // create dummy exception to force spring transaction manager to rollback rce = new TransactionRollbackException(); } if (!status.isRollbackOnly()) { status.setRollbackOnly(); } // throw runtime exception to force rollback (which works best to rollback with Spring transaction manager) if (log.isTraceEnabled()) { log.trace("Throwing runtime exception to force transaction to rollback on {}", transactionTemplate.getName()); } throw rce; } } });
@Override public void run() throws Throwable { // wrapper exception to throw if the exchange failed // IMPORTANT: Must be a runtime exception to let Spring regard // it as to do "rollback" Throwable rce; // and now let process the exchange by the error handler processByErrorHandler(exchange); // after handling and still an exception or marked as rollback // only then rollback if (exchange.getException() != null || exchange.isRollbackOnly()) { // wrap exception in transacted exception if (exchange.getException() != null) { rce = exchange.getException(); } else { // create dummy exception to force spring transaction // manager to rollback rce = new TransactionRolledbackException(); } // throw runtime exception to force rollback (which works // best to rollback with Spring transaction manager) if (log.isTraceEnabled()) { log.trace("Throwing runtime exception to force transaction to rollback on {}", transactionPolicy); } throw rce; } } });
RuntimeCamelException rce = null; if (exchange.isFailed() || exchange.isRollbackOnly()) { if (exchange.isRollbackOnly()) {