代码之家  ›  专栏  ›  技术社区  ›  Robbo_UK

Activiti用户界面Spring应用程序集成

  •  1
  • Robbo_UK  · 技术社区  · 7 年前

    .WAR 文件夹。已成功地将这些部署到本地主机

    到目前为止,我可以使用activiti应用程序生成BPMN文件并使用该接口启动应用程序。到现在为止,一直都还不错。

    所以看看 baeldung-activiti

    @GetMapping("/start-process")
    public String startProcess() {
        runtimeService.startProcessInstanceByKey("my-process");
        return "Process started. Number of currently running process instances = " + runtimeService.createProcessInstanceQuery().count();
    }
    

    每次命中端点时,上面的返回一个递增的值。

    我的问题是这个。

    使用activiti工具(运行于本地主机:8008)如何查看流程。如何链接独立java应用程序。(正在运行)本地主机:8081)使用Activiti ui界面?

    1 回复  |  直到 7 年前
        1
  •  1
  •   Babl    7 年前

    如果你有 activity-rest 已配置并正在运行。restapi是有文档记录的 here .

    因此,您只需要对正确的API端点执行Web服务调用。例如,列出您需要执行 GET 请求 repository/process-definitions 终结点。

    public void loadProcesses(){
        // the username and password to access the rest API (same as for UI)
        String plainCreds = "username:p@ssword";
        byte[] plainCredsBytes = plainCreds.getBytes();
        byte[] base64CredsBytes = Base64.getEncoder().encode(plainCredsBytes);
        String base64Creds = new String(base64CredsBytes);
    
        HttpHeaders headers = new HttpHeaders();
        headers.add("Authorization", "Basic " + base64Creds);
        RestTemplate restTemplate = new RestTemplate();
        HttpEntity<String> request = new HttpEntity<>(headers);
        ResponseEntity<String> responseAsJson = restTemplate.exchange("http://localhost:8080/activiti-rest/repository/process-definitions", HttpMethod.GET, request, String.class);
    }
    

    {
      "data": [
      {
        "id" : "oneTaskProcess:1:4",
        "url" : "http://localhost:8182/repository/process-definitions/oneTaskProcess%3A1%3A4",
        "version" : 1,
        "key" : "oneTaskProcess",
        "category" : "Examples",
        "suspended" : false,
        "name" : "The One Task Process",
        "description" : "This is a process for testing purposes",
        "deploymentId" : "2",
        "deploymentUrl" : "http://localhost:8081/repository/deployments/2",
        "graphicalNotationDefined" : true,
        "resource" : "http://localhost:8182/repository/deployments/2/resources/testProcess.xml",
        "diagramResource" : "http://localhost:8182/repository/deployments/2/resources/testProcess.png",
        "startFormDefined" : false
      }
      ],
      "total": 1,
      "start": 0,
      "sort": "name",
      "order": "asc",
      "size": 1
     }
    
    推荐文章