本文整理汇总了Java中org.camunda.bpm.engine.OptimisticLockingException类的典型用法代码示例。如果您正苦于以下问题:Java OptimisticLockingException类的具体用法?Java OptimisticLockingException怎么用?Java OptimisticLockingException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OptimisticLockingException类属于org.camunda.bpm.engine包,在下文中一共展示了OptimisticLockingException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invokeJobListener
import org.camunda.bpm.engine.OptimisticLockingException; //导入依赖的package包/类
protected static void invokeJobListener(CommandExecutor commandExecutor, JobFailureCollector jobFailureCollector) {
if(jobFailureCollector.getJobId() != null) {
if (jobFailureCollector.getFailure() != null) {
// the failed job listener is responsible for decrementing the retries and logging the exception to the DB.
FailedJobListener failedJobListener = createFailedJobListener(commandExecutor, jobFailureCollector.getFailure(), jobFailureCollector.getJobId());
OptimisticLockingException exception = callFailedJobListenerWithRetries(commandExecutor, failedJobListener);
if (exception != null) {
throw exception;
}
} else {
SuccessfulJobListener successListener = createSuccessfulJobListener(commandExecutor);
commandExecutor.execute(successListener);
}
}
}
示例2: testConcurrentTreeCompactionAndMessageCorrelation
import org.camunda.bpm.engine.OptimisticLockingException; //导入依赖的package包/类
@Deployment(resources = "org/camunda/bpm/engine/test/concurrency/CompetingMessageCorrelationTest.testConcurrentMessageCorrelationAndTreeCompaction.bpmn20.xml")
public void testConcurrentTreeCompactionAndMessageCorrelation() {
runtimeService.startProcessInstanceByKey("process");
List<Task> tasks = taskService.createTaskQuery().list();
// trigger tree compaction and wait before flush
ThreadControl taskCompletionThread = executeControllableCommand(new ControllableCompleteTaskCommand(tasks));
taskCompletionThread.reportInterrupts();
// stop task completion right before flush
taskCompletionThread.waitForSync();
// perform message correlation to non-interrupting boundary event
// (i.e. adds another concurrent execution to the scope execution)
runtimeService.correlateMessage("Message");
// flush task completion and tree compaction
taskCompletionThread.waitUntilDone();
// then it should not have succeeded
Throwable exception = taskCompletionThread.getException();
assertNotNull(exception);
assertTrue(exception instanceof OptimisticLockingException);
}
示例3: testCompetingJobExecutionDeleteJobDuringExecution
import org.camunda.bpm.engine.OptimisticLockingException; //导入依赖的package包/类
@Test
public void testCompetingJobExecutionDeleteJobDuringExecution() {
//given a simple process with a async service task
testRule.deploy(Bpmn
.createExecutableProcess("process")
.startEvent()
.serviceTask("task")
.camundaAsyncBefore()
.camundaExpression("${true}")
.endEvent()
.done());
runtimeService.startProcessInstanceByKey("process");
Job currentJob = managementService.createJobQuery().singleResult();
// when a job is executed
JobExecutionThread threadOne = new JobExecutionThread(currentJob.getId());
threadOne.startAndWaitUntilControlIsReturned();
//and deleted in parallel
managementService.deleteJob(currentJob.getId());
// then the job fails with a OLE and the failed job listener throws no NPE
LOG.debug("test thread notifies thread 1");
threadOne.proceedAndWaitTillDone();
assertTrue(threadOne.exception instanceof OptimisticLockingException);
}
示例4: testUserTaskOptimisticLocking
import org.camunda.bpm.engine.OptimisticLockingException; //导入依赖的package包/类
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
@Test
public void testUserTaskOptimisticLocking() {
runtimeService.startProcessInstanceByKey("oneTaskProcess");
Task task1 = taskService.createTaskQuery().singleResult();
Task task2 = taskService.createTaskQuery().singleResult();
task1.setDescription("test description one");
taskService.saveTask(task1);
try {
task2.setDescription("test description two");
taskService.saveTask(task2);
fail("Expecting exception");
} catch(OptimisticLockingException e) {
// Expected exception
}
}
示例5: testOptimisticLockingThrownOnMultipleUpdates
import org.camunda.bpm.engine.OptimisticLockingException; //导入依赖的package包/类
public void testOptimisticLockingThrownOnMultipleUpdates() {
Task task = taskService.newTask();
taskService.saveTask(task);
String taskId = task.getId();
// first modification
Task task1 = taskService.createTaskQuery().taskId(taskId).singleResult();
Task task2 = taskService.createTaskQuery().taskId(taskId).singleResult();
task1.setDescription("first modification");
taskService.saveTask(task1);
// second modification on the initial instance
task2.setDescription("second modification");
try {
taskService.saveTask(task2);
fail("should get an exception here as the task was modified by someone else.");
} catch (OptimisticLockingException expected) {
// exception was thrown as expected
}
taskService.deleteTask(taskId, true);
}
示例6: testUserTaskOptimisticLocking
import org.camunda.bpm.engine.OptimisticLockingException; //导入依赖的package包/类
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testUserTaskOptimisticLocking() {
runtimeService.startProcessInstanceByKey("oneTaskProcess");
thrown.expect(OptimisticLockingException.class);
Task task1 = taskService.createTaskQuery().singleResult();
Task task2 = taskService.createTaskQuery().singleResult();
task1.setDescription("test description one");
taskService.saveTask(task1);
task2.setDescription("test description two");
taskService.saveTask(task2);
}
示例7: testUserOptimisticLockingException
import org.camunda.bpm.engine.OptimisticLockingException; //导入依赖的package包/类
@Test
public void testUserOptimisticLockingException() {
User user = identityService.newUser("kermit");
identityService.saveUser(user);
User user1 = identityService.createUserQuery().singleResult();
User user2 = identityService.createUserQuery().singleResult();
user1.setFirstName("name one");
identityService.saveUser(user1);
thrown.expect(OptimisticLockingException.class);
user2.setFirstName("name two");
identityService.saveUser(user2);
}
示例8: testGroupOptimisticLockingException
import org.camunda.bpm.engine.OptimisticLockingException; //导入依赖的package包/类
@Test
public void testGroupOptimisticLockingException() {
Group group = identityService.newGroup("group");
identityService.saveGroup(group);
Group group1 = identityService.createGroupQuery().singleResult();
Group group2 = identityService.createGroupQuery().singleResult();
group1.setName("name one");
identityService.saveGroup(group1);
thrown.expect(OptimisticLockingException.class);
group2.setName("name two");
identityService.saveGroup(group2);
}
示例9: flushBatch
import org.camunda.bpm.engine.OptimisticLockingException; //导入依赖的package包/类
private void flushBatch(BatchStatement batch, long timestamp) {
if(batch==null){
return;
}
batch.setDefaultTimestamp(timestamp);
List<Row> rows = cassandraSession.execute(batch).all();
for (Row row : rows) {
if(!row.getBool("[applied]")) {
LockedBatch lb = lockedBatches.values().iterator().next();
LOG.log(Level.FINE, "flushBatch optimistic locking exception, version: "+ lb.getVersion());
throw new OptimisticLockingException("Process instance was updated by another transaction concurrently.");
}
}
}
示例10: checkPassword
import org.camunda.bpm.engine.OptimisticLockingException; //导入依赖的package包/类
public boolean checkPassword(String userId, String password) {
boolean isPassword = false;
try {
isPassword = commandExecutor.execute(new CheckPassword(userId, password));
} catch (OptimisticLockingException e) {
LOG.debugCaughtOptimisticLockingException(e);
}
return isPassword;
}
示例11: concurrentUpdateDbEntityException
import org.camunda.bpm.engine.OptimisticLockingException; //导入依赖的package包/类
public OptimisticLockingException concurrentUpdateDbEntityException(DbOperation operation) {
return new OptimisticLockingException(exceptionMessage(
"005",
"Execution of '{}' failed. Entity was updated by another transaction concurrently.",
operation
));
}
示例12: callFailedJobListenerWithRetries
import org.camunda.bpm.engine.OptimisticLockingException; //导入依赖的package包/类
/**
* Calls FailedJobListener, in case of OptimisticLockException retries configured amount of times.
*
* @return exception or null if succeeded
*/
private static OptimisticLockingException callFailedJobListenerWithRetries(CommandExecutor commandExecutor, FailedJobListener failedJobListener) {
try {
commandExecutor.execute(failedJobListener);
return null;
} catch (OptimisticLockingException ex) {
failedJobListener.incrementCountRetries();
if (failedJobListener.getRetriesLeft() > 0) {
return callFailedJobListenerWithRetries(commandExecutor, failedJobListener);
}
return ex;
}
}
示例13: run
import org.camunda.bpm.engine.OptimisticLockingException; //导入依赖的package包/类
public void run() {
try {
processEngineConfiguration
.getCommandExecutorTxRequired()
.execute(new ControlledCommand(activeThread, cmd));
} catch (OptimisticLockingException e) {
this.exception = e;
}
LOG.debug(getName()+" ends");
}
示例14: run
import org.camunda.bpm.engine.OptimisticLockingException; //导入依赖的package包/类
public void run() {
try {
processEngineConfiguration
.getCommandExecutorTxRequired()
.execute(new ControlledCommand(activeThread, new SignalCmd(executionId, null, null,null)));
} catch (OptimisticLockingException e) {
this.exception = e;
}
LOG.debug(getName()+" ends");
}
示例15: run
import org.camunda.bpm.engine.OptimisticLockingException; //导入依赖的package包/类
public void run() {
try {
processEngineConfiguration
.getCommandExecutorTxRequired()
.execute(new ControlledCommand(activeThread, new CompleteTaskCmd(taskId, null)));
} catch (OptimisticLockingException e) {
this.exception = e;
}
LOG.debug(getName()+" ends");
}