美文网首页
3.使用Workbench以及kie-server

3.使用Workbench以及kie-server

作者: 元代码 | 来源:发表于2018-06-20 12:13 被阅读0次

    安装Workbench以及kie-server

    https://blog.csdn.net/chinrui/article/details/79018351

    Workbench安装说明

    https://hub.docker.com/r/jboss/drools-workbench-showcase/

    kie-server安装说明

    https://hub.docker.com/r/jboss/kie-server-showcase/

    1.下载Workbench以及kie-server镜像

    docker pull jboss/drools-workbench-showcase
    

    showcase继承于jboss/drools-workbench:latest,增加了默认的用户和角色,还增加了一些例子

    docker pull jboss/kie-server-showcase:latest
    

    2.启动

    启动Workbench

    docker run -p 8080:8080 -p 8001:8001 -d --name drools-wb jboss/drools-workbench-showcase:latest
    

    启动kie-server

    docker run -p 8180:8080 -d --name kie-server --link drools-wb:kie_wb jboss/kie-server-showcase:latest
    
    docker run -p 8080:8080 -p 6001:8001 -d --name drools-wb jboss/drools-workbench-showcase:latest
    

    3.登录及使用Workbench

    http://localhost:8080/drools-wb

    使用用户名及密码登录

    USER PASSWORD ROLE ********************************************* admin admin admin,analyst,kiemgmt krisv krisv admin,analyst john john analyst,Accounting,PM sales-rep sales-rep analyst,sales katy katy analyst,HR jack jack analyst,IT

    https://github.com/wildfly/quickstart

    4.使用Workbench

    4.1新建项目




    4.2 Add Asset创建包、创建数据对象模型、规则文件、测试文件、发布规则



    a.创建包

    b.创建数据对象

    Address模型



    ApplyInfo模型

    c.创建规则

    规则名rule_001

    可以看到同报名的数据对象自动导入了
    通过编辑器配置规则

    d.创建测试场景testRule_001,增加fact

    运行测试场景
    e.发布规则
    首先设置 KieBase 与 KieSession,也就是配置 kmodule.xml 文件



    5.kie-server

    启动之后访问

    http://localhost:8180/kie-server/services/rest/server/

    kieserver/kieserver1!

    通过Workbench查看服务器可以看到已经关联了kie-server


    6.调用kie-server

    依赖

    <dependency>
    
    <groupId>org.kie.server</groupId>
    
    <artifactId>kie-server-client</artifactId>
    
    <version>7.7.0.Final</version>
    
    </dependency>
    

    调用kie-server代码

    public class Main {
    
    public static final String SERVER_URL = "http://localhost:6160/kie-server/services/rest/server";
    
    public static final String USERNAME = "kieserver";
    
    public static final String PASSWORD = "kieserver1!";
    
    public static final String KIE_CONTAINER_ID = "com.gao:hellodrools:1.0.0";
    
    public static void main(String[] args) {
    
    // KisService 配置信息设置
    
    KieServicesConfiguration kieServicesConfiguration =
    
    KieServicesFactory.newRestConfiguration(SERVER_URL, USERNAME, PASSWORD, 10000L);
    
    kieServicesConfiguration.setMarshallingFormat(MarshallingFormat.JSON);
    
    // 创建规则服务客户端
    
    KieServicesClient kieServicesClient = KieServicesFactory.newKieServicesClient(kieServicesConfiguration);
    
    RuleServicesClient ruleServicesClient = kieServicesClient.getServicesClient(RuleServicesClient.class);
    
    // 规则输入条件
    
    ApplyInfo applyInfo = new ApplyInfo();
    
    applyInfo.setAge(19);
    
    Address familyAddress = new Address();
    
    familyAddress.setProvince("aa");
    
    applyInfo.setFamilyAddress(familyAddress);
    
    // 命令定义,包含插入数据,执行规则
    
    KieCommands kieCommands = KieServices.Factory.get().getCommands();
    
    List<Command<?>> commands = new LinkedList<>();
    
    commands.add(kieCommands.newInsert(applyInfo, "applyInfo"));
    
    commands.add(kieCommands.newFireAllRules());
    
    ServiceResponse<ExecutionResults> results = ruleServicesClient.executeCommandsWithResults(KIE_CONTAINER_ID,
    
    kieCommands.newBatchExecution(commands, "ksessionId"));
    
    // 返回值读取
    
    ApplyInfo value = (ApplyInfo) results.getResult().getValue("applyInfo");
    
    System.out.println(value);
    
    }
    
    }
    

    java部署

    https://access.redhat.com/documentation/en-us/red_hat_jboss_brms/6.2/html/user_guide/rest_api_overview

    https://www.javatips.net/api/jbpm-examples-master/kie-server-test/src/main/java/org/jbpm/test/kieserver/KieExecutionServerClientTest.java

    https://blog.csdn.net/u013115157/article/details/52029545

    相关文章

      网友评论

          本文标题:3.使用Workbench以及kie-server

          本文链接:https://www.haomeiwen.com/subject/azntyftx.html