stepchain框架有什么作用
发表于:2025-12-02 作者:千家信息网编辑
千家信息网最后更新 2025年12月02日,本篇内容主要讲解"stepchain框架有什么作用",感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习"stepchain框架有什么作用"吧!stepchain
千家信息网最后更新 2025年12月02日stepchain框架有什么作用
本篇内容主要讲解"stepchain框架有什么作用",感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习"stepchain框架有什么作用"吧!
stepchain 通用业务流程流水线处理框架。
类似于Commons Chain和Commons Pipeline这样的Java Pipeline Step Chain用于组织复杂处理流程执行的流行技术。
Feature:1、支持通用业务job、services子流程无限制拆分。2、支持业务子流程串行化、业务子流程并行化,可配置化。3、支持Config业务子流程开启或禁用、配置串行或并行以及并行数的统一配置。4、支持业务流程以及子流程任意无限嵌套。5、支持配置中心、缓存、统一数据接口、redis、Es、日志Trace等。6、支持并行分支,支持条件分支if/else、switch、loop子流程.7、支持Processor定时调度FixedRate、FixedDelay。备注:只开源了通用部分(不影响使用),去除了有关框架组件包括:配置中心、缓存中心、数据接口以及业务相关DataMiddle等部分API。
Maven Dependency:Maven(Not Use Spring Boot):com.github.zengfr.project stepchain 0.0.7 Maven(Use Spring Boot): com.github.zengfr.project stepchain-spring-boot-starter 0.0.7 Gradle:compile group: 'com.github.zengfr.project', name: 'stepchain', version: '0.0.7'compile group: 'com.github.zengfr.project', name: 'stepchain-spring-boot-starter', version: '0.0.7'
1、StepChain 的中心思想是什么?如何做到通用的?答: 1.1、任何业务逻辑处理抽象成1\input输入 2\ processor处理器 3\output输出.中间过程结果产生和组合成dataMiddle。1.2、任何业务逻辑处理使用多个processor组合执行。2、StepChain 如何并行和串行执行多个processor?答: 串行step=pipeline.createStep();step.put(processors);//processors串行执行.并行step=pipeline.createStep(4);step.put(processors);//processors同时4个并行执行.3、Stepchain 如何创建processor? 3.1、实现 IProcessor 接口。 3.2、使用IProcessorBuilder: IProcessor createProcessor(Predicate predicate); IProcessor createProcessor(Consumer consumer); IProcessor createProcessor(Function func);4、StepChain 如何复用和组合processor? 4.1、使用IChainBuilder、IChain: 4.2、使用IProcessorBuilder: IProcessor createProcessor(IProcessor first, IProcessor second); IProcessor createProcessor(IProcessor processor1, IProcessor processor2, IProcessorprocessor3);5、StepChain 如何按条件复用和组合processor?答: case1、已有trueProcessor\falseProcessor2个 创建 validator 则按条件执行2则之1.IConditionSelectorProcessor p3 = pipeline.createConditionValidatorProcessor(validator, trueProcessor, falseProcessor);case2、已有processor 创建 validator 创建循环执行体,validator 返回false时终止执行。IConditionLoopProcessor p2 = pipeline.createConditionLoopProcessor(validator, processor);case3、已有processor创建 switch 逻辑,根据selector返回的key执行某1分支branchProcessor如果返回的key不在分支中 则执行默认key对应的分支branchProcessor。IConditionSelectorProcessor p1 = pipeline.createConditionSelectorProcessor(selector);p1.setBranch(S key, IProcessor processor);p1setDefaultBranch(S key);case4、已有processor创建 if/else if/else 逻辑,根据validator返回的结果与result对比一致则执行分支branchProcessor,如果没有返回一致的 则执行默认分支branchProcessor。pipeline.createConditionValidatorSelectorProcessor();public interface IConditionValidatorSelectorProcessor extends IProcessor { void setBranch(IProcessor validator,Boolean result,IProcessor processor); void setDefaultBranch(IProcessor processor);}
public interface IStep extends IStepProcessor { void put(IStepProcessor processor); void put(IStepProcessor... processorArray); void put(Collection> processors); void put(IProcessor processor); void put(IProcessor... processorArray); void put(IChain chain); void put(IChain... processorArray); void put(Function func); void put(Function... processorArray);}public interface IChain extends IProcessor { IChain next(IProcessor process); IChain next(Function func);}public interface IChainBuilder { IChain createChain(Function func); IChain createChain(IProcessor processor); IChain createChain(IProcessor processor1, IProcessor processor2);}public interface IStepBuilder { IStep createStep(); IStep createStep(int parallelCount); IStep createStep(String parallelCountConfigName);} StepChainSpringBootTest.java
PipelineTest.java
Demo&Test you can use AbstractProcessor AbstractStepProcessor
import com.github.zengfr.project.stepchainabstract class AbstractProcessor implements Processor{}abstract class AbstractStepProcessor extends AbstractProcessor implements StepProcessor{}import com.github.zengfr.project.stepchain.Chain;import com.github.zengfr.project.stepchain.Pipeline;import com.github.zengfr.project.stepchain.Step;import com.github.zengfr.project.stepchain.context.ContextBuilder;import com.github.zengfr.project.stepchain.context.UnaryContext;import com.github.zengfr.project.stepchain.test.context.SetProductContext;import com.github.zengfr.project.stepchain.test.context.SetProductDataMiddle;import com.github.zengfr.project.stepchain.test.processor.DiscountProcessor;import com.github.zengfr.project.stepchain.test.processor.FeeProcessor;import com.github.zengfr.project.stepchain.test.processor.IncreaseProcessor;import com.github.zengfr.project.stepchain.test.processor.InitProcessor;import com.github.zengfr.project.stepchain.test.processor.TaxProcessor;public class PipelineTest {public static void testPipeline(IPipeline pipeline) throws Exception { //Demo精简版 只开源了通用部分(不影响使用) SetProductRequest req = new SetProductRequest(); SetProductResponse resp = new SetProductResponse(); SetProductDataMiddle middle = new SetProductDataMiddle(); SetProductContext context = new SetProductContext(req, middle, resp); IStep step = pipeline.createStep(); step.put(new InitProcessor()); step.put(new TaxProcessor()); step.put(new FeeProcessor()); step.put(new IncreaseProcessor()); step.put(new DiscountProcessor()); step.put((c) -> { c.middle.Price += 10; return true; }); step.process(context); System.out.println(context.middle.Price); } public static void testPipeline2(IPipeline pipeline) throws Exception { Function, Boolean> func = (context) -> { if (context.context == null) context.context = 1; context.context += 1; return true; }; Function, String> func3 = (context) -> { if (context.context == null) context.context = 1; context.context += 1; return JSON.toJSONString(context.context); }; UnaryContext context = pipeline.createContext(12345678); IStep> step = pipeline.createStep(); IStep> step2 = pipeline.createStep(); IChain, Boolean> c2 = pipeline.createChain(func); IChain, String> c3 = pipeline.createChain(func3); Function func4 = null; Function func5 = null; Function func6 = null; IChain c4 = pipeline.createChain(func4); IChain c5 = pipeline.createChain(func5); IChain c6 = pipeline.createChain(func6); IChain, Boolean> c7 = c3.next(c4).next(c5).next(c6); step2.put(c2); step2.put(step); step2.put(func); //step2.put(c7); step2.process(context); System.out.println(context.context); } public static void testPipeline3(IPipeline pipeline) throws Exception { IProcessor selector = null; IProcessor validator = null; IProcessor processor = null; IProcessor first = null; IProcessor second = null; IConditionSelectorProcessor p3 = pipeline.createConditionValidatorProcessor(validator, first, second); IConditionLoopProcessor p2 = pipeline.createConditionLoopProcessor(validator, processor); IConditionSelectorProcessor p1 = pipeline.createConditionSelectorProcessor(selector); } @RunWith(SpringRunner.class)@SpringBootTest(classes = StepChainTestApplication.class)public class StepChainSpringBootTest { @Autowired protected IPipeline pipeline; @Test public void testPipeline() throws Exception { PipelineTest.testPipeline(pipeline); } @Test public void testPipeline2() throws Exception { PipelineTest.testPipeline2(pipeline); }
到此,相信大家对"stepchain框架有什么作用"有了更深的了解,不妨来实际操作一番吧!这里是网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
业务
流程
支持
分支
框架
处理
配置
逻辑
作用
接口
条件
部分
组合
一致
业务流程
内容
多个
数据
结果
缓存
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
清远数字软件开发价格走势
服务器密码定期自动修改管理
网络安全信息收集周报
重启服务器后tps恢复正常
深圳电商软件开发如何收费
连云港新品服务器价格
怎么把表格弄成数据库
奉化嵌入式软件开发设计
苹果的查找连接不到服务器
c++软件开发工程师
土地质量数据库在哪查
网络安全需要中间件吗
数据库设置自动增长
软件开发遇到资金风险怎么办
我为安全献一计网络安全口号
魔兽rp服务器能不能组队
江西省网络安全总队总工
外文数据库中布尔逻辑算符
语聊陪玩软件开发
游戏网站服务器维修费用
深圳立维互联网科技有限公司
服务器要求用户名和密码
规模大的视频会议软件开发
阿里云服务器退费后备案怎么办
团日活动网络安全总结咋写
号牌抓取软件开发
tcp 测试服务器
网络安全大赛河北
厦门首届网络安全宣传周
等保三级必备网络安全设备