Search in sources :

Example 1 with RouterHandler

use of io.seata.saga.proctrl.handler.RouterHandler in project seata by seata.

the class ProcessControllerTests method createProcessorController.

private ProcessControllerImpl createProcessorController(ProcessCtrlEventPublisher eventPublisher) throws Exception {
    DefaultRouterHandler defaultRouterHandler = new DefaultRouterHandler();
    defaultRouterHandler.setEventPublisher(eventPublisher);
    Map<String, ProcessRouter> processRouterMap = new HashMap<>(1);
    processRouterMap.put(ProcessType.STATE_LANG.getCode(), new MockProcessRouter());
    defaultRouterHandler.setProcessRouters(processRouterMap);
    CustomizeBusinessProcessor customizeBusinessProcessor = new CustomizeBusinessProcessor();
    Map<String, ProcessHandler> processHandlerMap = new HashMap<>(1);
    processHandlerMap.put(ProcessType.STATE_LANG.getCode(), new MockProcessHandler());
    customizeBusinessProcessor.setProcessHandlers(processHandlerMap);
    Map<String, RouterHandler> routerHandlerMap = new HashMap<>(1);
    routerHandlerMap.put(ProcessType.STATE_LANG.getCode(), defaultRouterHandler);
    customizeBusinessProcessor.setRouterHandlers(routerHandlerMap);
    ProcessControllerImpl processorController = new ProcessControllerImpl();
    processorController.setBusinessProcessor(customizeBusinessProcessor);
    return processorController;
}
Also used : DefaultRouterHandler(io.seata.saga.proctrl.handler.DefaultRouterHandler) CustomizeBusinessProcessor(io.seata.saga.proctrl.process.impl.CustomizeBusinessProcessor) HashMap(java.util.HashMap) MockProcessRouter(io.seata.saga.proctrl.mock.MockProcessRouter) MockProcessHandler(io.seata.saga.proctrl.mock.MockProcessHandler) ProcessControllerImpl(io.seata.saga.proctrl.impl.ProcessControllerImpl) RouterHandler(io.seata.saga.proctrl.handler.RouterHandler) DefaultRouterHandler(io.seata.saga.proctrl.handler.DefaultRouterHandler) MockProcessRouter(io.seata.saga.proctrl.mock.MockProcessRouter) ProcessHandler(io.seata.saga.proctrl.handler.ProcessHandler) MockProcessHandler(io.seata.saga.proctrl.mock.MockProcessHandler)

Example 2 with RouterHandler

use of io.seata.saga.proctrl.handler.RouterHandler 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)

Example 3 with RouterHandler

use of io.seata.saga.proctrl.handler.RouterHandler in project seata by seata.

the class DefaultStateMachineConfig method createProcessorController.

protected ProcessControllerImpl createProcessorController(ProcessCtrlEventPublisher eventPublisher) throws Exception {
    StateMachineProcessRouter stateMachineProcessRouter = new StateMachineProcessRouter();
    stateMachineProcessRouter.initDefaultStateRouters();
    loadStateRouterInterceptors(stateMachineProcessRouter.getStateRouters());
    StateMachineProcessHandler stateMachineProcessHandler = new StateMachineProcessHandler();
    stateMachineProcessHandler.initDefaultHandlers();
    loadStateHandlerInterceptors(stateMachineProcessHandler.getStateHandlers());
    DefaultRouterHandler defaultRouterHandler = new DefaultRouterHandler();
    defaultRouterHandler.setEventPublisher(eventPublisher);
    Map<String, ProcessRouter> processRouterMap = new HashMap<>(1);
    processRouterMap.put(ProcessType.STATE_LANG.getCode(), stateMachineProcessRouter);
    defaultRouterHandler.setProcessRouters(processRouterMap);
    CustomizeBusinessProcessor customizeBusinessProcessor = new CustomizeBusinessProcessor();
    Map<String, ProcessHandler> processHandlerMap = new HashMap<>(1);
    processHandlerMap.put(ProcessType.STATE_LANG.getCode(), stateMachineProcessHandler);
    customizeBusinessProcessor.setProcessHandlers(processHandlerMap);
    Map<String, RouterHandler> routerHandlerMap = new HashMap<>(1);
    routerHandlerMap.put(ProcessType.STATE_LANG.getCode(), defaultRouterHandler);
    customizeBusinessProcessor.setRouterHandlers(routerHandlerMap);
    ProcessControllerImpl processorController = new ProcessControllerImpl();
    processorController.setBusinessProcessor(customizeBusinessProcessor);
    return processorController;
}
Also used : DefaultRouterHandler(io.seata.saga.proctrl.handler.DefaultRouterHandler) CustomizeBusinessProcessor(io.seata.saga.proctrl.process.impl.CustomizeBusinessProcessor) StateMachineProcessHandler(io.seata.saga.engine.pcext.StateMachineProcessHandler) HashMap(java.util.HashMap) StateMachineProcessRouter(io.seata.saga.engine.pcext.StateMachineProcessRouter) ProcessRouter(io.seata.saga.proctrl.ProcessRouter) ProcessControllerImpl(io.seata.saga.proctrl.impl.ProcessControllerImpl) StateMachineProcessRouter(io.seata.saga.engine.pcext.StateMachineProcessRouter) DefaultRouterHandler(io.seata.saga.proctrl.handler.DefaultRouterHandler) RouterHandler(io.seata.saga.proctrl.handler.RouterHandler) ProcessHandler(io.seata.saga.proctrl.handler.ProcessHandler) StateMachineProcessHandler(io.seata.saga.engine.pcext.StateMachineProcessHandler)

Aggregations

RouterHandler (io.seata.saga.proctrl.handler.RouterHandler)3 DefaultRouterHandler (io.seata.saga.proctrl.handler.DefaultRouterHandler)2 ProcessHandler (io.seata.saga.proctrl.handler.ProcessHandler)2 ProcessControllerImpl (io.seata.saga.proctrl.impl.ProcessControllerImpl)2 CustomizeBusinessProcessor (io.seata.saga.proctrl.process.impl.CustomizeBusinessProcessor)2 HashMap (java.util.HashMap)2 StateMachineProcessHandler (io.seata.saga.engine.pcext.StateMachineProcessHandler)1 StateMachineProcessRouter (io.seata.saga.engine.pcext.StateMachineProcessRouter)1 ProcessRouter (io.seata.saga.proctrl.ProcessRouter)1 ProcessType (io.seata.saga.proctrl.ProcessType)1 MockProcessHandler (io.seata.saga.proctrl.mock.MockProcessHandler)1 MockProcessRouter (io.seata.saga.proctrl.mock.MockProcessRouter)1