1. 历史信息存储级别
camunda工作流的数据都存储在数据库中,历史数据会非常大,可以根据需要,选择存储历史数据的级别,camunda支持的级别如下:
full:所有历史数据都被保存,包括变量的更新。
audit:只有历史的流程实例、活动实例、表单数据等会被保存。
auto:数据库之前配置的是什么级别就是什么级别,如果没有配置,则是audit级别。
none:不存储历史数据。
实际验证发现只能是没有数据的时候可以设置,不能有数据后随意更改,这点设置有点奇怪。
2. RestApi
camunda7.18版本的RestApi文档:camunda-community-hub.github.io/camunda-pla…
(1) Maven依赖,需要使用jdk11或以上版本
<dependency>
<groupId>org.camunda.community.rest</groupId>
<artifactId>camunda-platform-7-rest-client-spring-boot-starter</artifactId>
<version>7.18.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
<version>2.13.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.13.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-kotlin</artifactId>
<version>2.13.3</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>3.1.3</version>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-httpclient</artifactId>
<version>11.8</version>
</dependency>
(2) 在客户端启动类上添加@EnableCamundaRestClient注解
(3) 在配置文件中添加如下内容:
feign.client:
config:
processInstance.url: http://ip:port/engine-rest
processDefinition.url: http://ip:port/engine-rest
message.url: http://ip:port/engine-rest
signal.url: http://ip:port/engine-rest
execution.url: http://ip:port/engine-rest
task.url: http://ip:port/engine-rest
taskVariable.url: http://ip:port/engine-rest
taskLocalVariable.url: http://ip:port/engine-rest
taskIdentityLink.url: http://ip:port/engine-rest
externalTask.url: http://ip:port/engine-rest
incident.url: http://ip:port/engine-rest
historicProcessInstance.url: http://ip:port/engine-rest
deployment.url: http://ip:port/engine-rest
(4) 添加rest权限验证
由于引擎端对rest接口开启了权限验证,需要增加访问的Basic Auth,代码如下:
@Configuration
public class FeignAuthConfig {
@Autowired
private ClientProperties clientProperties;
@Bean
public BasicAuthRequestInterceptor basicAuthRequestInterceptor(){
return new BasicAuthRequestInterceptor(clientProperties.getBasicAuth().getUsername(),clientProperties.getBasicAuth().getPassword());
}
}
(5)添加测试类
添加一个controller类,来测试调用远程REST API,就像是调用本地API一样。@Qualifier("remote")注解很重要,注入远程实现api。
java9以后移除了javax.xml.bind模块,启动时自动生成类失败后,添加javax依赖 implementation 'javax.xml.bind:jaxb-api:2.3.0'
restapi调试
可以将camunda中restapi的jar包导入到postman或者swagger editor中进行调试。
api接口的jar包地址