Solon v3.0.3

::liteflow-solon-plugin [国产]

</> markdown
<dependency>
     <groupId>com.yomahub</groupId>
    <artifactId>liteflow-solon-plugin</artifactId>
    <version>最新版本</version>
</dependency>

1、描述

规则引擎 liteflow(代码仓库)的适配插件。

2、配置示例

  • 添加应用配置

在 app.yml 添加配置(指定规则源)

liteflow.rule-source: "config/flow.el.xml"
  • 同时,在 resources 下的 config/flow.el.xml 中配置规则流:
<?xml version="1.0" encoding="UTF-8"?>
<flow>
  <chain name="chain1">
    THEN(a, b, c);
  </chain>
</flow>

3、代码应用

  • 实现节点组件

定义并实现一些组件,确保 Solon 会扫描到这些组件并注册进上下文。

@Component("a")
public class ACmp extends NodeComponent {
  @Override
  public void process() {
    //do your business
  }
}

以此类推再分别定义b,c组件:

@Component("b")
public class BCmp extends NodeComponent {
  @Override
  public void process() {
    //do your business
  }
}

@Component("c")
public class CCmp extends NodeComponent {
  @Override
  public void process() {
    //do your business
  }
}
  • 实现执行规则
@Component
public class TestService{
  @Inject
  private FlowExecutor flowExecutor;
  
  public void testConfig(){
    LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
  }
}