Search in sources :

Example 1 with ProcessType

use of io.seata.saga.proctrl.ProcessType in project seata by seata.

the class DefaultRouterHandler method route.

@Override
public void route(ProcessContext context) throws FrameworkException {
    try {
        ProcessType processType = matchProcessType(context);
        if (processType == null) {
            if (LOGGER.isWarnEnabled()) {
                LOGGER.warn("Process type not found, context= {}", context);
            }
            throw new FrameworkException(FrameworkErrorCode.ProcessTypeNotFound);
        }
        ProcessRouter processRouter = processRouters.get(processType.getCode());
        if (processRouter == null) {
            LOGGER.error("Cannot find process router by type {}, context = {}", processType.getCode(), context);
            throw new FrameworkException(FrameworkErrorCode.ProcessRouterNotFound);
        }
        Instruction instruction = processRouter.route(context);
        if (instruction == null) {
            LOGGER.info("route instruction is null, process end");
        } else {
            context.setInstruction(instruction);
            eventPublisher.publish(context);
        }
    } catch (FrameworkException e) {
        throw e;
    } catch (Exception ex) {
        throw new FrameworkException(ex, ex.getMessage(), FrameworkErrorCode.UnknownAppError);
    }
}
Also used : ProcessType(io.seata.saga.proctrl.ProcessType) FrameworkException(io.seata.common.exception.FrameworkException) ProcessRouter(io.seata.saga.proctrl.ProcessRouter) Instruction(io.seata.saga.proctrl.Instruction) FrameworkException(io.seata.common.exception.FrameworkException)

Example 2 with ProcessType

use of io.seata.saga.proctrl.ProcessType in project seata by seata.

the class CustomizeBusinessProcessor method process.

@Override
public void process(ProcessContext context) throws FrameworkException {
    ProcessType processType = matchProcessType(context);
    if (processType == null) {
        if (LOGGER.isWarnEnabled()) {
            LOGGER.warn("Process type not found, context= {}", context);
        }
        throw new FrameworkException(FrameworkErrorCode.ProcessTypeNotFound);
    }
    ProcessHandler processor = processHandlers.get(processType.getCode());
    if (processor == null) {
        LOGGER.error("Cannot find process handler by type {}, context= {}", processType.getCode(), context);
        throw new FrameworkException(FrameworkErrorCode.ProcessHandlerNotFound);
    }
    processor.process(context);
}
Also used : ProcessType(io.seata.saga.proctrl.ProcessType) FrameworkException(io.seata.common.exception.FrameworkException) ProcessHandler(io.seata.saga.proctrl.handler.ProcessHandler)

Example 3 with ProcessType

use of io.seata.saga.proctrl.ProcessType in project seata by seata.

the class CustomizeBusinessProcessor method route.

@Override
public void route(ProcessContext context) throws FrameworkException {
    ProcessType processType = matchProcessType(context);
    if (processType == null) {
        if (LOGGER.isWarnEnabled()) {
            LOGGER.warn("Process type not found, the process is no longer advanced, context= {}", context);
        }
        return;
    }
    RouterHandler router = routerHandlers.get(processType.getCode());
    if (router == null) {
        LOGGER.error("Cannot find router handler by type {}, context= {}", processType.getCode(), context);
        return;
    }
    router.route(context);
}
Also used : ProcessType(io.seata.saga.proctrl.ProcessType) RouterHandler(io.seata.saga.proctrl.handler.RouterHandler)

Aggregations

ProcessType (io.seata.saga.proctrl.ProcessType)3 FrameworkException (io.seata.common.exception.FrameworkException)2 Instruction (io.seata.saga.proctrl.Instruction)1 ProcessRouter (io.seata.saga.proctrl.ProcessRouter)1 ProcessHandler (io.seata.saga.proctrl.handler.ProcessHandler)1 RouterHandler (io.seata.saga.proctrl.handler.RouterHandler)1