Search in sources :

Example 26 with TransactionException

use of io.seata.core.exception.TransactionException in project seata by seata.

the class AbstractTCInboundHandler method handle.

@Override
public GlobalBeginResponse handle(GlobalBeginRequest request, final RpcContext rpcContext) {
    GlobalBeginResponse response = new GlobalBeginResponse();
    exceptionHandleTemplate(new AbstractCallback<GlobalBeginRequest, GlobalBeginResponse>() {

        @Override
        public void execute(GlobalBeginRequest request, GlobalBeginResponse response) throws TransactionException {
            try {
                doGlobalBegin(request, response, rpcContext);
            } catch (StoreException e) {
                throw new TransactionException(TransactionExceptionCode.FailedStore, String.format("begin global request failed. xid=%s, msg=%s", response.getXid(), e.getMessage()), e);
            }
        }
    }, request, response);
    return response;
}
Also used : GlobalBeginRequest(io.seata.core.protocol.transaction.GlobalBeginRequest) TransactionException(io.seata.core.exception.TransactionException) GlobalBeginResponse(io.seata.core.protocol.transaction.GlobalBeginResponse) StoreException(io.seata.common.exception.StoreException)

Example 27 with TransactionException

use of io.seata.core.exception.TransactionException in project seata by seata.

the class AbstractTCInboundHandler method handle.

@Override
public GlobalStatusResponse handle(GlobalStatusRequest request, final RpcContext rpcContext) {
    GlobalStatusResponse response = new GlobalStatusResponse();
    response.setGlobalStatus(GlobalStatus.UnKnown);
    exceptionHandleTemplate(new AbstractCallback<GlobalStatusRequest, GlobalStatusResponse>() {

        @Override
        public void execute(GlobalStatusRequest request, GlobalStatusResponse response) throws TransactionException {
            try {
                doGlobalStatus(request, response, rpcContext);
            } catch (StoreException e) {
                throw new TransactionException(TransactionExceptionCode.FailedStore, String.format("global status request failed. xid=%s, msg=%s", request.getXid(), e.getMessage()), e);
            }
        }

        @Override
        public void onTransactionException(GlobalStatusRequest request, GlobalStatusResponse response, TransactionException tex) {
            super.onTransactionException(request, response, tex);
            checkTransactionStatus(request, response);
        }

        @Override
        public void onException(GlobalStatusRequest request, GlobalStatusResponse response, Exception rex) {
            super.onException(request, response, rex);
            checkTransactionStatus(request, response);
        }
    }, request, response);
    return response;
}
Also used : TransactionException(io.seata.core.exception.TransactionException) GlobalStatusRequest(io.seata.core.protocol.transaction.GlobalStatusRequest) TransactionException(io.seata.core.exception.TransactionException) StoreException(io.seata.common.exception.StoreException) GlobalStatusResponse(io.seata.core.protocol.transaction.GlobalStatusResponse) StoreException(io.seata.common.exception.StoreException)

Example 28 with TransactionException

use of io.seata.core.exception.TransactionException in project seata by seata.

the class AbstractTCInboundHandler method handle.

@Override
public BranchRegisterResponse handle(BranchRegisterRequest request, final RpcContext rpcContext) {
    BranchRegisterResponse response = new BranchRegisterResponse();
    exceptionHandleTemplate(new AbstractCallback<BranchRegisterRequest, BranchRegisterResponse>() {

        @Override
        public void execute(BranchRegisterRequest request, BranchRegisterResponse response) throws TransactionException {
            try {
                doBranchRegister(request, response, rpcContext);
            } catch (StoreException e) {
                throw new TransactionException(TransactionExceptionCode.FailedStore, String.format("branch register request failed. xid=%s, msg=%s", request.getXid(), e.getMessage()), e);
            }
        }
    }, request, response);
    return response;
}
Also used : TransactionException(io.seata.core.exception.TransactionException) BranchRegisterResponse(io.seata.core.protocol.transaction.BranchRegisterResponse) BranchRegisterRequest(io.seata.core.protocol.transaction.BranchRegisterRequest) StoreException(io.seata.common.exception.StoreException)

Example 29 with TransactionException

use of io.seata.core.exception.TransactionException in project seata by seata.

the class AbstractTCInboundHandler method handle.

@Override
public GlobalCommitResponse handle(GlobalCommitRequest request, final RpcContext rpcContext) {
    GlobalCommitResponse response = new GlobalCommitResponse();
    response.setGlobalStatus(GlobalStatus.Committing);
    exceptionHandleTemplate(new AbstractCallback<GlobalCommitRequest, GlobalCommitResponse>() {

        @Override
        public void execute(GlobalCommitRequest request, GlobalCommitResponse response) throws TransactionException {
            try {
                doGlobalCommit(request, response, rpcContext);
            } catch (StoreException e) {
                throw new TransactionException(TransactionExceptionCode.FailedStore, String.format("global commit request failed. xid=%s, msg=%s", request.getXid(), e.getMessage()), e);
            }
        }

        @Override
        public void onTransactionException(GlobalCommitRequest request, GlobalCommitResponse response, TransactionException tex) {
            super.onTransactionException(request, response, tex);
            checkTransactionStatus(request, response);
        }

        @Override
        public void onException(GlobalCommitRequest request, GlobalCommitResponse response, Exception rex) {
            super.onException(request, response, rex);
            checkTransactionStatus(request, response);
        }
    }, request, response);
    return response;
}
Also used : GlobalCommitRequest(io.seata.core.protocol.transaction.GlobalCommitRequest) TransactionException(io.seata.core.exception.TransactionException) GlobalCommitResponse(io.seata.core.protocol.transaction.GlobalCommitResponse) TransactionException(io.seata.core.exception.TransactionException) StoreException(io.seata.common.exception.StoreException) StoreException(io.seata.common.exception.StoreException)

Example 30 with TransactionException

use of io.seata.core.exception.TransactionException in project seata by seata.

the class StateMachineDBTests method getGlobalTransaction.

private GlobalTransaction getGlobalTransaction(StateMachineInstance instance) {
    GlobalTransaction globalTransaction = null;
    Map<String, Object> params = instance.getContext();
    if (params != null) {
        globalTransaction = (GlobalTransaction) params.get(DomainConstants.VAR_NAME_GLOBAL_TX);
    }
    if (globalTransaction == null) {
        try {
            globalTransaction = GlobalTransactionContext.reload(instance.getId());
        } catch (TransactionException e) {
            e.printStackTrace();
        }
    }
    return globalTransaction;
}
Also used : TransactionException(io.seata.core.exception.TransactionException) GlobalTransaction(io.seata.tm.api.GlobalTransaction)

Aggregations

TransactionException (io.seata.core.exception.TransactionException)54 BranchStatus (io.seata.core.model.BranchStatus)14 GlobalSession (io.seata.server.session.GlobalSession)9 ShouldNeverHappenException (io.seata.common.exception.ShouldNeverHappenException)7 StoreException (io.seata.common.exception.StoreException)7 ExecutionException (io.seata.tm.api.TransactionalExecutor.ExecutionException)6 GlobalTransaction (io.seata.tm.api.GlobalTransaction)5 IOException (java.io.IOException)5 TimeoutException (java.util.concurrent.TimeoutException)5 NotSupportYetException (io.seata.common.exception.NotSupportYetException)4 GlobalTransactionEvent (io.seata.core.event.GlobalTransactionEvent)4 GlobalTransactionException (io.seata.core.exception.GlobalTransactionException)4 GlobalStatus (io.seata.core.model.GlobalStatus)4 EngineExecutionException (io.seata.saga.engine.exception.EngineExecutionException)4 BranchSession (io.seata.server.session.BranchSession)4 SQLException (java.sql.SQLException)4 StateMachineInstance (io.seata.saga.statelang.domain.StateMachineInstance)3 TransactionalExecutor (io.seata.tm.api.TransactionalExecutor)3 XAException (javax.transaction.xa.XAException)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3