Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * Copyright (c) 2010-2011. Axon Framework
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
 package org.axonframework.eventhandling.transactionmanagers;
TransactionManager implementation that uses a org.springframework.transaction.PlatformTransactionManager as underlying transaction manager.

The transaction manager will commit the transaction when event handling is successful. If a non-transient (non-recoverable) exception occurs, the failing event is discarded and the transaction is committed. If a transient exception occurs, such as a failing connection, the transaction is rolled back and scheduled for a retry.

Allard Buijze
 public class SpringTransactionManager implements TransactionManager {
     private static final Logger logger = LoggerFactory.getLogger(SpringTransactionManager.class);
     public void beforeTransaction(TransactionStatus transactionStatus) {
     public void afterTransaction(TransactionStatus transactionStatus) {
         if (transactionStatus.isSuccessful()) {
         } else {
             .warn("Found failed transaction: [{}]."transactionStatus.getException().getClass().getSimpleName());
             if (!isTransient(transactionStatus.getException())) {
                 .error("ERROR! Exception is not transient or recoverable! Committing transaction and "
                                      + "skipping Event processing"transactionStatus.getException());
             } else {
                 .warn("Performing rollback on transaction due to recoverable exception: [{}]",
                 if (.get() != null) {

The PlatformTransactionManager that manages the transactions with the underlying data source.

transactionManager the transaction manager that manages transactions with underlying data sources
     public void setTransactionManager(PlatformTransactionManager transactionManager) {
         this. = transactionManager;
     private boolean isTransient(Throwable exception) {
         if (exception instanceof SQLTransientException || exception instanceof SQLRecoverableException) {
             return true;
         if (exception.getCause() != null && exception.getCause() != exception) {
             return isTransient(exception.getCause());
         return false;
New to GrepCode? Check out our FAQ X