Appearance
suspendProcessDefinitionById
Flowable 7.1.0 摘要:根据流程定义ID挂起流程定义。
方法签名与说明
void suspendProcessDefinitionById(String processDefinitionId)
挂起指定ID的流程定义。挂起后无法启动新的流程实例。
Parameters:
- processDefinitionId - 流程定义ID
Throws:
- FlowableObjectNotFoundException - 当流程定义不存在时
void suspendProcessDefinitionById(String processDefinitionId, boolean suspendProcessInstances, Date suspensionDate)
挂起流程定义,可选择是否同时挂起流程实例,并可指定挂起时间。
Parameters:
- processDefinitionId - 流程定义ID
- suspendProcessInstances - 是否同时挂起流程实例
- suspensionDate - 挂起生效时间
常见使用场景
1. 精确控制版本
需要挂起特定版本的流程定义,而不影响其他版本。
2. 流程实例相关操作
在挂起流程定义时,同时处理该定义下的所有流程实例。
Kotlin + Spring Boot 调用示例
kotlin
import org.flowable.engine.RepositoryService
import org.springframework.stereotype.Service
@Service
class ProcessVersionSuspensionService(
private val repositoryService: RepositoryService
) {
/**
* 挂起特定版本的流程定义
* 企业场景:只挂起V1版本,保留V2版本运行
*/
fun suspendSpecificVersion(processDefinitionId: String) {
val processDefinition = repositoryService.getProcessDefinition(processDefinitionId)
println("挂起流程: ${processDefinition.name} V${processDefinition.version}")
repositoryService.suspendProcessDefinitionById(processDefinitionId)
println("挂起成功,流程ID: $processDefinitionId")
}
}相关 API
RepositoryService.suspendProcessDefinitionById()- 按ID挂起RepositoryService.suspendProcessDefinitionByKey()- 按Key挂起RepositoryService.activateProcessDefinitionById()- 按ID激活
本文档说明
- 基于 Flowable 7.1.0 版本编写
- 所有示例均可直接在 Spring Boot + Kotlin 项目中使用