當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。