我有以下Activiti 6应用程序通过官方提供的.WAR文件运行。已成功将它们部署到我的本地主机
到目前为止,我可以使用activiti-app生成BPMN文件并使用该界面启动应用程序。到目前为止一切顺利。
但是我想做的是编写自己的Spring Apps,但能够使用activiti UI应用查看它们的运行情况。
因此,请看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工具(在localhost:8008上运行)如何查看进程。如何链接独立的Java应用程序。 (在localhost:8081上运行)并带有Activiti ui接口?
答案 0 :(得分:1)
如果已配置并运行activity-rest
,那将非常容易。 REST API已记录在here中。
因此,您只需要对正确的API端点进行Web服务调用即可。例如,要列出所有进程,您需要向GET
端点发出repository/process-definitions
请求。
注意:Rest API使用基本身份验证。
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);
}
以下API调用的响应将为JSON
{
"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
}