Camunda Rest API

发布时间:2024年01月11日

客户端像调用本地方法一样调用引擎中的接口。

https://docs.camunda.org/manual/7.17/reference/rest/

一:pom.xml

<dependency>
    <groupId>org.camunda.community.rest</groupId>
    <artifactId>camunda-platform-7-rest-client-spring-boot-starter</artifactId>
    <version>7.17.2</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>

二:application.yml

server:
  port: 8081

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/camunda?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&&nullCatalogMeansCurrent=true
    username: root
    password: root123
    driver-class-name: com.mysql.cj.jdbc.Driver

camunda:
  bpm:
    client:
      base-url: http://localhost:8080/engine-rest
      max-tasks: 1
      worker-id: springboot-camunda-client
      async-response-timeout: 20000
      lock-duration: 10000
      basic-auth:
        username: admin
        password: 123456

feign:
  client:
    config:
      processInstance.url: ${camunda.bpm.client.base-url}
      processDefinition.url: ${camunda.bpm.client.base-url}
      message.url: ${camunda.bpm.client.base-url}
      signal.url: ${camunda.bpm.client.base-url}
      execution.url: ${camunda.bpm.client.base-url}
      task.url: ${camunda.bpm.client.base-url}
      taskVariable.url: ${camunda.bpm.client.base-url}
      taskLocalVariable.url: ${camunda.bpm.client.base-url}
      taskIdentityLink.url: ${camunda.bpm.client.base-url}
      externalTask.url: ${camunda.bpm.client.base-url}
      incident.url: ${camunda.bpm.client.base-url}
      historicProcessInstance.url: ${camunda.bpm.client.base-url}
      deployment.url: ${camunda.bpm.client.base-url}

三:开启

@SpringBootApplication
@EnableCamundaRestClient
public class SprigbootCamundaClientApplication {

    public static void main(String[] args) {
        SpringApplication.run(SprigbootCamundaClientApplication.class, args);
    }
}

四:test

package com.example.client;


import org.camunda.bpm.engine.HistoryService;
import org.camunda.bpm.engine.RepositoryService;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.repository.Deployment;
import org.camunda.bpm.engine.repository.ProcessDefinition;
import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class RestClientTestController {
    private RuntimeService runtimeService;

    private RepositoryService repositoryService;

    private HistoryService historyService;

    public RestClientTestController(@Qualifier("remote")RuntimeService runtimeService,
                                     @Qualifier("remote")RepositoryService repositoryService,@Qualifier("remote")HistoryService historyService) {
        this.runtimeService = runtimeService;
        this.repositoryService = repositoryService;
        this.historyService = historyService;
    }

    @GetMapping("/test")
    public List<Deployment> test() {
        List<Deployment> list = repositoryService.createDeploymentQuery().list();
        return list;
    }
}

在这里插入图片描述

文章来源:https://blog.csdn.net/vbirdbest/article/details/135532076
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。