org.activiti.engine.impl.RuntimeServiceImpl#startProcessInstanceByKey

The org.activiti.engine.impl.RuntimeServiceImpl#startProcessInstanceByKey(String, Map<String, Object>) method is used to start a new process instance in the Activiti engine based on the provided process definition key and process variables.

Here's how you can use this method:

  1. Process Definition Key: Pass the key of the process definition you want to start as the first parameter. This key is defined in your BPMN XML file.

  2. Process Variables: Pass a map of process variables as the second parameter. These variables can be used within your process definition to control its behavior.

Here's an example of how to use this method:

 
import org.activiti.engine.RuntimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class ProcessService {

    @Autowired
    private RuntimeService runtimeService;

    public void startProcessInstanceByKey(String processDefinitionKey) {
        // Define process variables
        Map<String, Object> variables = new HashMap<>();
        variables.put("variable1", "value1");
        variables.put("variable2", 123);

        // Start process instance
        runtimeService.startProcessInstanceByKey(processDefinitionKey, variables);
    }
}

In this example:

  • processDefinitionKey is the key of the process definition you want to start.
  • variables is a map containing process variables. These variables will be available within the process instance and can be used in BPMN tasks, gateways, etc.

Make sure to replace "variable1", "value1", "variable2", and 123 with your actual variable names and values.

Remember that the process definition key must correspond to an existing process definition deployed in your Activiti engine. If the process definition contains any required variables, make sure to provide them in the variables map.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值