Camunda Spring-Boot REST 客户端 逃离我推掉我的手 2022-11-15 14:09 207阅读 0赞 # Camunda Spring-Boot REST 客户端 # github仓库地址: [camunda-rest-client-spring-boot][] ## 1.增加依赖 ## <properties> <camunda-rest-client-spring-boot.version>0.0.3</camunda-rest-client-spring-boot.version> <spring-cloud.version>Hoxton.SR2</spring-cloud.version> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring-cloud.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>org.camunda.bpm.extension.rest</groupId> <artifactId>camunda-rest-client-spring-boot-starter</artifactId> <version>${camunda-rest-client-spring-boot.version}</version> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> </dependency> <dependency> <groupId>io.github.openfeign</groupId> <artifactId>feign-httpclient</artifactId> </dependency> </dependencies> ## 2.配置 ## 在客户端代码中增加配置,使用`@EnableCamundaRestClient`激活`REST client`。 @Configuration @EnableCamundaRestClient public class MyClientConfiguration { } 在工程中的`application.yml`文件中增加`feign`配置。 feign: client: config: remoteRuntimeService: url: "http://your-process-engine-host/rest/engine/default/" ## 3.使用 ## 需要访问远程API时,注入远程API。 @Component public class MyClient { private RuntimeService runtimeService; public MyClient(@Qualifier("remote") RuntimeService runtimeService) { this.runtimeService = runtimeService; } public void start() { this.runtimeService .startProcessInstanceByKey("my_process_key"); } public void correlate() { this.runtimeService .createMessageCorrelation("message_received") .processInstanceBusinessKey("WAIT_FOR_MESSAGE") .correlateAllWithResult(); } } [camunda-rest-client-spring-boot]: https://github.com/camunda/camunda-rest-client-spring-boot/
还没有评论,来说两句吧...