当前位置: 首页>>代码示例>>Java>>正文


Java OptimisticLockingException类代码示例

本文整理汇总了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);
    }
  }
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:19,代码来源:ExecuteJobHelper.java

示例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);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:25,代码来源:CompetingMessageCorrelationTest.java

示例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);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:26,代码来源:ConcurrentJobExecutorTest.java

示例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
  }
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:21,代码来源:TaskServiceTest.java

示例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);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:24,代码来源:StandaloneTaskTest.java

示例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);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:17,代码来源:TaskServiceWithJdbcSimpleProcessingTest.java

示例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);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:17,代码来源:IdentityServiceTest.java

示例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);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:17,代码来源:IdentityServiceTest.java

示例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.");
    }
  }
}
 
开发者ID:camunda,项目名称:camunda-engine-cassandra,代码行数:16,代码来源:CassandraPersistenceSession.java

示例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;
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:10,代码来源:IdentityServiceImpl.java

示例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
  ));
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:8,代码来源:EnginePersistenceLogger.java

示例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;
  }
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:18,代码来源:ExecuteJobHelper.java

示例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");
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:12,代码来源:CompetingSentrySatisfactionTest.java

示例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");
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:12,代码来源:CompetingJoinTest.java

示例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");
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:12,代码来源:CompetingSubprocessCompletionTest.java


注:本文中的org.camunda.bpm.engine.OptimisticLockingException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。