本文整理汇总了Java中org.camunda.bpm.engine.runtime.ProcessInstance.getProcessInstanceId方法的典型用法代码示例。如果您正苦于以下问题:Java ProcessInstance.getProcessInstanceId方法的具体用法?Java ProcessInstance.getProcessInstanceId怎么用?Java ProcessInstance.getProcessInstanceId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.camunda.bpm.engine.runtime.ProcessInstance
的用法示例。
在下文中一共展示了ProcessInstance.getProcessInstanceId方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRetryGlobalConfiguration
import org.camunda.bpm.engine.runtime.ProcessInstance; //导入方法依赖的package包/类
@Test
public void testRetryGlobalConfiguration() throws ParseException {
// given global retry conf. ("PT5M,PT20M, PT3M")
BpmnModelInstance bpmnModelInstance = prepareProcessFailingServiceTask();
testRule.deploy(bpmnModelInstance);
ClockUtil.setCurrentTime(SIMPLE_DATE_FORMAT.parse("2017-01-01T09:55:00"));
ProcessInstance pi = runtimeService.startProcessInstanceByKey(PROCESS_ID);
Date currentTime = SIMPLE_DATE_FORMAT.parse("2017-01-01T10:00:00");
ClockUtil.setCurrentTime(currentTime);
String processInstanceId = pi.getProcessInstanceId();
int jobRetries = executeJob(processInstanceId);
assertEquals(3, jobRetries);
currentTime = DateUtils.addMinutes(currentTime, 5);
assertLockExpirationTime(currentTime);
ClockUtil.setCurrentTime(currentTime);
jobRetries = executeJob(processInstanceId);
assertEquals(2, jobRetries);
currentTime = DateUtils.addMinutes(currentTime, 20);
assertLockExpirationTime(currentTime);
ClockUtil.setCurrentTime(currentTime);
jobRetries = executeJob(processInstanceId);
assertEquals(1, jobRetries);
currentTime = DateUtils.addMinutes(currentTime, 3);
assertLockExpirationTime(currentTime);
ClockUtil.setCurrentTime(currentTime);
jobRetries = executeJob(processInstanceId);
assertEquals(0, jobRetries);
}
示例2: testSingleRetryInterval
import org.camunda.bpm.engine.runtime.ProcessInstance; //导入方法依赖的package包/类
@Test
public void testSingleRetryInterval() throws ParseException {
// given
BpmnModelInstance bpmnModelInstance = prepareProcessFailingServiceTaskWithRetryCycle("PT8M ");
testRule.deploy(bpmnModelInstance);
ClockUtil.setCurrentTime(SIMPLE_DATE_FORMAT.parse("2017-01-01T09:55:00"));
ProcessInstance pi = runtimeService.startProcessInstanceByKey(PROCESS_ID);
assertNotNull(pi);
Date currentTime = SIMPLE_DATE_FORMAT.parse("2017-01-01T10:00:00");
ClockUtil.setCurrentTime(currentTime);
String processInstanceId = pi.getProcessInstanceId();
int jobRetries = executeJob(processInstanceId);
assertEquals(1, jobRetries);
currentTime = DateUtils.addMinutes(currentTime, 8);
assertLockExpirationTime(currentTime);
ClockUtil.setCurrentTime(currentTime);
jobRetries = executeJob(processInstanceId);
assertEquals(0, jobRetries);
}
示例3: testRetryGlobalConfigurationWithExecutionListener
import org.camunda.bpm.engine.runtime.ProcessInstance; //导入方法依赖的package包/类
@Test
public void testRetryGlobalConfigurationWithExecutionListener() throws ParseException {
// given
engineRule.getProcessEngineConfiguration().setFailedJobRetryTimeCycle("PT5M");
BpmnModelInstance bpmnModelInstance = Bpmn.createExecutableProcess(PROCESS_ID)
.startEvent()
.serviceTask()
.camundaClass(FAILING_CLASS)
.camundaAsyncBefore()
.camundaExecutionListenerClass(RecorderExecutionListener.EVENTNAME_START, RecorderExecutionListener.class.getName())
.endEvent()
.done();
testRule.deploy(bpmnModelInstance);
ClockUtil.setCurrentTime(SIMPLE_DATE_FORMAT.parse("2017-01-01T09:55:00"));
ProcessInstance pi = runtimeService.startProcessInstanceByKey(PROCESS_ID);
Date currentTime = SIMPLE_DATE_FORMAT.parse("2017-01-01T10:00:00");
ClockUtil.setCurrentTime(currentTime);
String processInstanceId = pi.getProcessInstanceId();
int jobRetries = executeJob(processInstanceId);
assertEquals(1, jobRetries);
currentTime = DateUtils.addMinutes(currentTime, 5);
assertLockExpirationTime(currentTime);
ClockUtil.setCurrentTime(currentTime);
jobRetries = executeJob(processInstanceId);
assertEquals(0, jobRetries);
}
示例4: testRetryMixConfiguration
import org.camunda.bpm.engine.runtime.ProcessInstance; //导入方法依赖的package包/类
@Test
public void testRetryMixConfiguration() throws ParseException {
// given
BpmnModelInstance bpmnModelInstance = prepareProcessFailingServiceTaskWithRetryCycle("R3/PT1M");
testRule.deploy(bpmnModelInstance);
ClockUtil.setCurrentTime(SIMPLE_DATE_FORMAT.parse("2017-01-01T09:55:00"));
ProcessInstance pi = runtimeService.startProcessInstanceByKey(PROCESS_ID);
assertNotNull(pi);
Date currentTime = SIMPLE_DATE_FORMAT.parse("2017-01-01T10:00:00");
ClockUtil.setCurrentTime(currentTime);
String processInstanceId = pi.getProcessInstanceId();
int jobRetries;
for (int i = 0; i < 3; i++) {
jobRetries = executeJob(processInstanceId);
assertEquals(2 - i, jobRetries);
currentTime = DateUtils.addMinutes(currentTime, 1);
assertLockExpirationTime(currentTime);
ClockUtil.setCurrentTime(currentTime);
}
}
示例5: testRetryIntervals
import org.camunda.bpm.engine.runtime.ProcessInstance; //导入方法依赖的package包/类
@Test
public void testRetryIntervals() throws ParseException {
// given
BpmnModelInstance bpmnModelInstance = prepareProcessFailingServiceTaskWithRetryCycle("PT3M, PT10M,PT8M");
testRule.deploy(bpmnModelInstance);
ClockUtil.setCurrentTime(SIMPLE_DATE_FORMAT.parse("2017-01-01T09:55:00"));
ProcessInstance pi = runtimeService.startProcessInstanceByKey(PROCESS_ID);
assertNotNull(pi);
Date currentTime = SIMPLE_DATE_FORMAT.parse("2017-01-01T10:00:00");
ClockUtil.setCurrentTime(currentTime);
String processInstanceId = pi.getProcessInstanceId();
int jobRetries = executeJob(processInstanceId);
assertEquals(3, jobRetries);
currentTime = DateUtils.addMinutes(currentTime, 3);
assertLockExpirationTime(currentTime);
ClockUtil.setCurrentTime(currentTime);
jobRetries = executeJob(processInstanceId);
assertEquals(2, jobRetries);
currentTime = DateUtils.addMinutes(currentTime, 10);
assertLockExpirationTime(currentTime);
ClockUtil.setCurrentTime(currentTime);
jobRetries = executeJob(processInstanceId);
assertEquals(1, jobRetries);
currentTime = DateUtils.addMinutes(currentTime, 8);
assertLockExpirationTime(currentTime);
ClockUtil.setCurrentTime(currentTime);
jobRetries = executeJob(processInstanceId);
assertEquals(0, jobRetries);
}
示例6: testVersionUpgradeShouldCancelJobs
import org.camunda.bpm.engine.runtime.ProcessInstance; //导入方法依赖的package包/类
@Deployment
public void testVersionUpgradeShouldCancelJobs() throws Exception {
ClockUtil.setCurrentTime(new Date());
// After process start, there should be timer created
JobQuery jobQuery = managementService.createJobQuery();
assertEquals(1, jobQuery.count());
// we deploy new process version, with some small change
InputStream in = getClass().getResourceAsStream("StartTimerEventTest.testVersionUpgradeShouldCancelJobs.bpmn20.xml");
String process = new String(IoUtil.readInputStream(in, "")).replaceAll("beforeChange", "changed");
IoUtil.closeSilently(in);
in = new ByteArrayInputStream(process.getBytes());
String id = repositoryService.createDeployment().addInputStream("StartTimerEventTest.testVersionUpgradeShouldCancelJobs.bpmn20.xml", in).deploy().getId();
IoUtil.closeSilently(in);
assertEquals(1, jobQuery.count());
moveByMinutes(5);
executeAllJobs();
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExample").singleResult();
String pi = processInstance.getProcessInstanceId();
assertEquals("changed", runtimeService.getActiveActivityIds(pi).get(0));
assertEquals(1, jobQuery.count());
// cleanDB();
repositoryService.deleteDeployment(id, true);
}
示例7: run
import org.camunda.bpm.engine.runtime.ProcessInstance; //导入方法依赖的package包/类
/**
* this code instantiates a business process that in turn delegates to a few Spring beans that in turn inject a process scoped object, {@link StatefulObject}.
*
* @return the StatefulObject that was injected across different components, that all share the same state.
* @throws Throwable if anythign goes wrong
*/
private StatefulObject run() throws Throwable {
logger.info("----------------------------------------------");
Map<String, Object> vars = new HashMap<String, Object>();
vars.put(customerIdProcVarName, CUSTOMER_ID_PROC_VAR_VALUE);
ProcessInstance processInstance = processEngine.getRuntimeService().startProcessInstanceByKey("component-waiter", vars);
StatefulObject scopedObject = (StatefulObject) processEngine.getRuntimeService().getVariable(processInstance.getId(), "scopedTarget.c1");
Assert.assertNotNull("the scopedObject can't be null", scopedObject);
Assert.assertTrue("the 'name' property can't be null.", StringUtils.hasText(scopedObject.getName()));
Assert.assertEquals(scopedObject.getVisitedCount(), 2);
// the process has paused
String procId = processInstance.getProcessInstanceId();
List<Task> tasks = taskService.createTaskQuery().executionId(procId).list();
Assert.assertEquals("there should be 1 (one) task enqueued at this point.", tasks.size(), 1);
Task t = tasks.iterator().next();
this.taskService.claim(t.getId(), "me");
logger.info("sleeping for 10 seconds while a user performs his task. " +
"The first transaction has committed. A new one will start in 10 seconds");
Thread.sleep(1000 * 5);
this.taskService.complete(t.getId());
scopedObject = (StatefulObject) processEngine.getRuntimeService().getVariable(processInstance.getId(), "scopedTarget.c1");
Assert.assertEquals(scopedObject.getVisitedCount(), 3);
Assert.assertEquals( "the customerId injected should " +
"be what was given as a processVariable parameter." ,
ScopingTest.CUSTOMER_ID_PROC_VAR_VALUE, scopedObject.getCustomerId()) ;
return scopedObject;
}
示例8: testIntervalsAfterUpdateRetries
import org.camunda.bpm.engine.runtime.ProcessInstance; //导入方法依赖的package包/类
@Test
public void testIntervalsAfterUpdateRetries() throws ParseException {
// given
BpmnModelInstance bpmnModelInstance = prepareProcessFailingServiceTaskWithRetryCycle("PT3M, PT10M,PT8M");
testRule.deploy(bpmnModelInstance);
ClockUtil.setCurrentTime(SIMPLE_DATE_FORMAT.parse("2017-01-01T09:55:00"));
ProcessInstance pi = runtimeService.startProcessInstanceByKey(PROCESS_ID);
assertNotNull(pi);
Date currentTime = SIMPLE_DATE_FORMAT.parse("2017-01-01T10:00:00");
ClockUtil.setCurrentTime(currentTime);
String processInstanceId = pi.getProcessInstanceId();
int jobRetries = executeJob(processInstanceId);
assertEquals(3, jobRetries);
currentTime = DateUtils.addMinutes(currentTime, 3);
assertLockExpirationTime(currentTime);
ClockUtil.setCurrentTime(currentTime);
Job job = managementService.createJobQuery().processInstanceId(processInstanceId).singleResult();
managementService.setJobRetries(Arrays.asList(job.getId()), 5);
jobRetries = executeJob(processInstanceId);
assertEquals(4, jobRetries);
currentTime = DateUtils.addMinutes(currentTime, 3);
assertLockExpirationTime(currentTime);
ClockUtil.setCurrentTime(currentTime);
jobRetries = executeJob(processInstanceId);
assertEquals(3, jobRetries);
currentTime = DateUtils.addMinutes(currentTime, 3);
assertLockExpirationTime(currentTime);
ClockUtil.setCurrentTime(currentTime);
jobRetries = executeJob(processInstanceId);
assertEquals(2, jobRetries);
currentTime = DateUtils.addMinutes(currentTime, 10);
assertLockExpirationTime(currentTime);
ClockUtil.setCurrentTime(currentTime);
jobRetries = executeJob(processInstanceId);
assertEquals(1, jobRetries);
currentTime = DateUtils.addMinutes(currentTime, 8);
assertLockExpirationTime(currentTime);
ClockUtil.setCurrentTime(currentTime);
jobRetries = executeJob(processInstanceId);
assertEquals(0, jobRetries);
}
示例9: testMixConfigurationWithinOneProcess
import org.camunda.bpm.engine.runtime.ProcessInstance; //导入方法依赖的package包/类
@Test
public void testMixConfigurationWithinOneProcess() throws ParseException {
// given
BpmnModelInstance bpmnModelInstance = Bpmn.createExecutableProcess(PROCESS_ID)
.startEvent()
.serviceTask("Task1")
.camundaClass(ServiceTaskDelegate.class.getName())
.camundaAsyncBefore()
.serviceTask("Task2")
.camundaClass(FAILING_CLASS)
.camundaAsyncBefore()
.camundaFailedJobRetryTimeCycle("PT3M, PT10M,PT8M")
.endEvent()
.done();
testRule.deploy(bpmnModelInstance);
ClockUtil.setCurrentTime(SIMPLE_DATE_FORMAT.parse("2017-01-01T09:55:00"));
ProcessInstance pi = runtimeService.startProcessInstanceByKey(PROCESS_ID);
assertNotNull(pi);
Date currentTime = SIMPLE_DATE_FORMAT.parse("2017-01-01T10:00:00");
ClockUtil.setCurrentTime(currentTime);
String processInstanceId = pi.getProcessInstanceId();
// try to execute the first service task without success
int jobRetries = executeJob(processInstanceId);
assertEquals(3, jobRetries);
currentTime = DateUtils.addMinutes(currentTime, 5);
assertLockExpirationTime(currentTime);
ClockUtil.setCurrentTime(currentTime);
ServiceTaskDelegate.firstAttempt = false;
// finish the first service task
jobRetries = executeJob(processInstanceId);
assertEquals(3, jobRetries);
// try to execute the second service task without success
jobRetries = executeJob(processInstanceId);
assertEquals(3, jobRetries);
currentTime = DateUtils.addMinutes(currentTime, 3);
assertLockExpirationTime(currentTime);
ClockUtil.setCurrentTime(currentTime);
}
示例10: testlocalConfigurationWithNestedChangingExpression
import org.camunda.bpm.engine.runtime.ProcessInstance; //导入方法依赖的package包/类
@Test
public void testlocalConfigurationWithNestedChangingExpression() throws ParseException {
BpmnModelInstance bpmnModelInstance = Bpmn.createExecutableProcess("process")
.startEvent()
.serviceTask()
.camundaClass("foo")
.camundaAsyncBefore()
.camundaFailedJobRetryTimeCycle("${var}")
.endEvent()
.done();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
Date startDate = simpleDateFormat.parse("2017-01-01T09:55:00");
ClockUtil.setCurrentTime(startDate);
testRule.deploy(bpmnModelInstance);
VariableMap params = Variables.createVariables();
params.putValue("var", "${nestedVar1},PT15M,${nestedVar3}");
params.putValue("nestedVar", "PT13M");
params.putValue("nestedVar1", "PT5M");
params.putValue("nestedVar3", "PT25M");
ProcessInstance pi = runtimeService.startProcessInstanceByKey("process", params);
ClockUtil.setCurrentTime(SIMPLE_DATE_FORMAT.parse("2017-01-01T09:55:00"));
assertNotNull(pi);
Date currentTime = SIMPLE_DATE_FORMAT.parse("2017-01-01T10:00:00");
ClockUtil.setCurrentTime(currentTime);
String processInstanceId = pi.getProcessInstanceId();
int jobRetries = executeJob(processInstanceId);
assertEquals(3, jobRetries);
currentTime = DateUtils.addMinutes(currentTime, 5);
assertLockExpirationTime(currentTime);
ClockUtil.setCurrentTime(currentTime);
jobRetries = executeJob(processInstanceId);
assertEquals(2, jobRetries);
currentTime = DateUtils.addMinutes(currentTime, 15);
assertLockExpirationTime(currentTime);
ClockUtil.setCurrentTime(currentTime);
runtimeService.setVariable(pi.getProcessInstanceId(), "var", "${nestedVar}");
jobRetries = executeJob(processInstanceId);
assertEquals(1, jobRetries);
currentTime = DateUtils.addMinutes(currentTime, 13);
assertLockExpirationTime(currentTime);
ClockUtil.setCurrentTime(currentTime);
jobRetries = executeJob(processInstanceId);
assertEquals(0, jobRetries);
}