• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ActivitiOptimisticLockingException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.activiti.engine.ActivitiOptimisticLockingException的典型用法代码示例。如果您正苦于以下问题:Java ActivitiOptimisticLockingException类的具体用法?Java ActivitiOptimisticLockingException怎么用?Java ActivitiOptimisticLockingException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ActivitiOptimisticLockingException类属于org.activiti.engine包,在下文中一共展示了ActivitiOptimisticLockingException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: deleteProcessInstance

import org.activiti.engine.ActivitiOptimisticLockingException; //导入依赖的package包/类
public void deleteProcessInstance(String userId, String processInstanceId, String deleteReason) {
    try {
        engine.getIdentityService().setAuthenticatedUserId(userId);

        long deadline = System.currentTimeMillis() + DEFAULT_ABORT_TIMEOUT_MS;
        while (true) {
            try {
                LOGGER.debug(format(Messages.SETTING_VARIABLE, Constants.PROCESS_ABORTED, Boolean.TRUE));
                // TODO: Use execution ID instead of process instance ID, as they can be
                // different if the process has parallel executions.
                engine.getRuntimeService().setVariable(processInstanceId, Constants.PROCESS_ABORTED, Boolean.TRUE);
                LOGGER.debug(format(Messages.SET_SUCCESSFULLY, Constants.PROCESS_ABORTED));

                engine.getRuntimeService().deleteProcessInstance(processInstanceId, deleteReason);
                break;
            } catch (ActivitiOptimisticLockingException e) {
                if (isPastDeadline(deadline)) {
                    throw new IllegalStateException(Messages.ABORT_OPERATION_TIMED_OUT, e);
                }
                LOGGER.warn(format(Messages.RETRYING_PROCESS_ABORT, processInstanceId));
            }
        }
    } finally {
        engine.getIdentityService().setAuthenticatedUserId(null);
    }
}
 
开发者ID:SAP,项目名称:cf-mta-deploy-service,代码行数:27,代码来源:ActivitiFacade.java


示例2: unlockJobIsNeeded

import org.activiti.engine.ActivitiOptimisticLockingException; //导入依赖的package包/类
protected static void unlockJobIsNeeded(final JobEntity job, final CommandExecutor commandExecutor) {
    try {
        if (job.isExclusive()) {
            commandExecutor.execute(new UnlockExclusiveJobCmd(job));
        }

    } catch (ActivitiOptimisticLockingException optimisticLockingException) {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Optimistic locking exception while unlocking the job. If you have multiple async executors running against the same database, " +
                    "this exception means that this thread tried to acquire an exclusive job, which already was changed by another async executor thread." +
                    "This is expected behavior in a clustered environment. " +
                    "You can ignore this message if you indeed have multiple job executor acquisition threads running against the same database. " +
                    "Exception message: {}", optimisticLockingException.getMessage());
        }
    } catch (Throwable t) {
        LOGGER.error("Error while unlocking exclusive job {}", job.getId(), t);
    }
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:19,代码来源:AsyncJobUtil.java


示例3: execute

import org.activiti.engine.ActivitiOptimisticLockingException; //导入依赖的package包/类
@Override
public <T> T execute(CommandConfig config, Command<T> command) {
    long waitTime = waitTimeInMs;
    int failedAttempts = 0;

    do {
        if (failedAttempts > 0) {
            LOGGER.info("Waiting for {}ms before retrying the command.", waitTime);
            waitBeforeRetry(waitTime);
            waitTime *= waitIncreaseFactor;
        }

        try {

            // try to execute the command
            return next.execute(config, command);

        } catch (ActivitiOptimisticLockingException e) {
            LOGGER.info("Caught optimistic locking exception: {}", e.getMessage(), e);
        }

        failedAttempts++;
    } while (failedAttempts <= numOfRetries);

    throw new ActivitiException(numOfRetries + " retries failed with ActivitiOptimisticLockingException. Giving up.");
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:27,代码来源:RetryInterceptor.java


示例4: updateProcessInstanceLockTime

import org.activiti.engine.ActivitiOptimisticLockingException; //导入依赖的package包/类
public void updateProcessInstanceLockTime(String processInstanceId) {
    CommandContext commandContext = Context.getCommandContext();
    Date expirationTime = commandContext.getProcessEngineConfiguration().getClock().getCurrentTime();
    int lockMillis = commandContext.getProcessEngineConfiguration().getAsyncExecutorAsyncJobLockTimeInMillis();
    GregorianCalendar lockCal = new GregorianCalendar();
    lockCal.setTime(expirationTime);
    lockCal.add(Calendar.MILLISECOND, lockMillis);

    HashMap<String, Object> params = new HashMap<>();
    params.put("id", processInstanceId);
    params.put("lockTime", lockCal.getTime());
    params.put("expirationTime", expirationTime);

    int result = getDbSqlSession().update("updateProcessInstanceLockTime", params);
    if (result == 0) {
        throw new ActivitiOptimisticLockingException("Could not lock process instance");
    }
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:19,代码来源:ExecutionEntityManager.java


示例5: execute

import org.activiti.engine.ActivitiOptimisticLockingException; //导入依赖的package包/类
@Override
public void execute() {
    String deleteStatement = dbSqlSessionFactory.getDeleteStatement(persistentObject.getClass());
    deleteStatement = dbSqlSessionFactory.mapStatement(deleteStatement);
    if (deleteStatement == null) {
        throw new ActivitiException("no delete statement for " + persistentObject.getClass() + " in the ibatis mapping files");
    }

    // It only makes sense to check for optimistic locking exceptions for objects that actually have a revision
    if (persistentObject instanceof HasRevision) {
        int nrOfRowsDeleted = sqlSession.delete(deleteStatement, persistentObject);
        if (nrOfRowsDeleted == 0) {
            throw new ActivitiOptimisticLockingException(persistentObject + " was updated by another transaction concurrently");
        }
    } else {
        sqlSession.delete(deleteStatement, persistentObject);
    }
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:19,代码来源:DbSqlSession.java


示例6: flushUpdates

import org.activiti.engine.ActivitiOptimisticLockingException; //导入依赖的package包/类
protected void flushUpdates(List<PersistentObject> updatedObjects) {
    for (PersistentObject updatedObject : updatedObjects) {
        String updateStatement = dbSqlSessionFactory.getUpdateStatement(updatedObject);
        updateStatement = dbSqlSessionFactory.mapStatement(updateStatement);

        if (updateStatement == null) {
            throw new ActivitiException("no update statement for " + updatedObject.getClass() + " in the ibatis mapping files");
        }

        LOGGER.debug("updating: {}", updatedObject);
        int updatedRecords = sqlSession.update(updateStatement, updatedObject);
        if (updatedRecords != 1) {
            throw new ActivitiOptimisticLockingException(updatedObject + " was updated by another transaction concurrently");
        }

        // See https://activiti.atlassian.net/browse/ACT-1290
        if (updatedObject instanceof HasRevision) {
            ((HasRevision) updatedObject).setRevision(((HasRevision) updatedObject).getRevisionNext());
        }

    }
    updatedObjects.clear();
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:24,代码来源:DbSqlSession.java


示例7: execute

import org.activiti.engine.ActivitiOptimisticLockingException; //导入依赖的package包/类
public <T> T execute(Command<T> command) {
  long waitTime=waitTimeInMs;
  int failedAttempts=0;   
  
  do {      
    if (failedAttempts > 0) {
      log.info( "Waiting for "+waitTime+"ms before retrying the command." );
      waitBeforeRetry(waitTime);
      waitTime *= waitIncreaseFactor;
    }

    try {

      // try to execute the command
      return next.execute(command);

    } catch (ActivitiOptimisticLockingException e) {
      log.log(Level.INFO, "Caught optimistic locking exception: "+e);
    }
          
    failedAttempts ++;      
  } while(failedAttempts<=numOfRetries);

  throw new ActivitiException(numOfRetries + " retries failed with ActivitiOptimisticLockingException. Giving up.");
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:26,代码来源:RetryInterceptor.java


示例8: execute

import org.activiti.engine.ActivitiOptimisticLockingException; //导入依赖的package包/类
public <T> T execute(CommandConfig config, Command<T> command) {
  long waitTime=waitTimeInMs;
  int failedAttempts=0;   
  
  do {      
    if (failedAttempts > 0) {
      log.info( "Waiting for {}ms before retrying the command.", waitTime);
      waitBeforeRetry(waitTime);
      waitTime *= waitIncreaseFactor;
    }

    try {

      // try to execute the command
      return next.execute(config, command);

    } catch (ActivitiOptimisticLockingException e) {
      log.info("Caught optimistic locking exception: "+e);
    }
          
    failedAttempts ++;      
  } while(failedAttempts<=numOfRetries);

  throw new ActivitiException(numOfRetries + " retries failed with ActivitiOptimisticLockingException. Giving up.");
}
 
开发者ID:springvelocity,项目名称:xbpm5,代码行数:26,代码来源:RetryInterceptor.java


示例9: execute

import org.activiti.engine.ActivitiOptimisticLockingException; //导入依赖的package包/类
public void execute() {
  String deleteStatement = dbSqlSessionFactory.getDeleteStatement(persistentObject.getClass());
  deleteStatement = dbSqlSessionFactory.mapStatement(deleteStatement);
  if (deleteStatement == null) {
    throw new ActivitiException("no delete statement for " + persistentObject.getClass() + " in the ibatis mapping files");
  }
  
  // It only makes sense to check for optimistic locking exceptions for objects that actually have a revision
  if (persistentObject instanceof HasRevision) {
    int nrOfRowsDeleted = sqlSession.delete(deleteStatement, persistentObject);
    if (nrOfRowsDeleted == 0) {
      throw new ActivitiOptimisticLockingException(persistentObject + " was updated by another transaction concurrently");
    }
  } else {
    sqlSession.delete(deleteStatement, persistentObject);
  }
}
 
开发者ID:springvelocity,项目名称:xbpm5,代码行数:18,代码来源:DbSqlSession.java


示例10: flushUpdates

import org.activiti.engine.ActivitiOptimisticLockingException; //导入依赖的package包/类
protected void flushUpdates(List<PersistentObject> updatedObjects) {
  for (PersistentObject updatedObject: updatedObjects) {
    String updateStatement = dbSqlSessionFactory.getUpdateStatement(updatedObject);
    updateStatement = dbSqlSessionFactory.mapStatement(updateStatement);
    
    if (updateStatement==null) {
      throw new ActivitiException("no update statement for "+updatedObject.getClass()+" in the ibatis mapping files");
    }
    
    log.debug("updating: {}", updatedObject);
    int updatedRecords = sqlSession.update(updateStatement, updatedObject);
    if (updatedRecords!=1) {
      throw new ActivitiOptimisticLockingException(updatedObject + " was updated by another transaction concurrently");
    } 
    
    // See http://jira.codehaus.org/browse/ACT-1290
    if (updatedObject instanceof HasRevision) {
      ((HasRevision) updatedObject).setRevision(((HasRevision) updatedObject).getRevisionNext());
    }
    
  }
  updatedObjects.clear();
}
 
开发者ID:springvelocity,项目名称:xbpm5,代码行数:24,代码来源:DbSqlSession.java


示例11: testOptimisticLockingThrownOnMultipleUpdates

import org.activiti.engine.ActivitiOptimisticLockingException; //导入依赖的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 (ActivitiOptimisticLockingException expected) {
    //  exception was thrown as expected
  }
  
  taskService.deleteTask(taskId, true);
}
 
开发者ID:springvelocity,项目名称:xbpm5,代码行数:24,代码来源:StandaloneTaskTest.java


示例12: testUserTaskOptimisticLocking

import org.activiti.engine.ActivitiOptimisticLockingException; //导入依赖的package包/类
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
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(ActivitiOptimisticLockingException e) {
    // Expected exception
  }
}
 
开发者ID:springvelocity,项目名称:xbpm5,代码行数:20,代码来源:TaskServiceTest.java


示例13: testUserOptimisticLockingException

import org.activiti.engine.ActivitiOptimisticLockingException; //导入依赖的package包/类
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);

  try {
    
    user2.setFirstName("name two");
    identityService.saveUser(user2);
    
    fail("Expected an exception");
  } catch (ActivitiOptimisticLockingException e) {
    // Expected an exception
  }
  
  identityService.deleteUser(user.getId());
}
 
开发者ID:springvelocity,项目名称:xbpm5,代码行数:23,代码来源:IdentityServiceTest.java


示例14: testGroupOptimisticLockingException

import org.activiti.engine.ActivitiOptimisticLockingException; //导入依赖的package包/类
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);

  try {
    
    group2.setName("name two");
    identityService.saveGroup(group2);
    
    fail("Expected an exception");
  } catch (ActivitiOptimisticLockingException e) {
    // Expected an exception
  }
  
  identityService.deleteGroup(group.getId());
}
 
开发者ID:springvelocity,项目名称:xbpm5,代码行数:23,代码来源:IdentityServiceTest.java


示例15: flushUpdates

import org.activiti.engine.ActivitiOptimisticLockingException; //导入依赖的package包/类
protected void flushUpdates(List<PersistentObject> updatedObjects) {
  for (PersistentObject updatedObject: updatedObjects) {
    String updateStatement = dbSqlSessionFactory.getUpdateStatement(updatedObject);
    updateStatement = dbSqlSessionFactory.mapStatement(updateStatement);
    if (updateStatement==null) {
      throw new ActivitiException("no update statement for "+updatedObject.getClass()+" in the ibatis mapping files");
    }
    log.fine("updating: "+toString(updatedObject)+"]");
    int updatedRecords = sqlSession.update(updateStatement, updatedObject);
    if (updatedRecords!=1) {
      throw new ActivitiOptimisticLockingException(toString(updatedObject)+" was updated by another transaction concurrently");
    }
  }
  updatedObjects.clear();
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:16,代码来源:DbSqlSession.java


示例16: run

import org.activiti.engine.ActivitiOptimisticLockingException; //导入依赖的package包/类
public void run() {
  try {
    processEngineConfiguration
      .getCommandExecutorTxRequired()
      .execute(new ControlledCommand(activeThread, new SignalCmd(executionId, null, null)));

  } catch (ActivitiOptimisticLockingException e) {
    this.exception = e;
  }
  log.fine(getName()+" ends");
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:12,代码来源:CompetingJoinTest.java


示例17: run

import org.activiti.engine.ActivitiOptimisticLockingException; //导入依赖的package包/类
public void run() {
  try {
    JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();
    processEngineConfiguration
      .getCommandExecutorTxRequired()
      .execute(new ControlledCommand(activeThread, new AcquireJobsCmd(jobExecutor)));

  } catch (ActivitiOptimisticLockingException e) {
    this.exception = e;
  }
  log.fine(getName()+" ends");
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:13,代码来源:CompetingJobAcquisitionTest.java


示例18: run

import org.activiti.engine.ActivitiOptimisticLockingException; //导入依赖的package包/类
public void run() {
  try {
    runtimeService.signal(executionId);
  } catch (ActivitiOptimisticLockingException e) {
    this.exception = e;
  }
  log.fine(getName()+" ends");
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:9,代码来源:CompetingSignalsTest.java


示例19: run

import org.activiti.engine.ActivitiOptimisticLockingException; //导入依赖的package包/类
public void run() {
  try {
    processEngineConfiguration
      .getCommandExecutorTxRequired()
      .execute(new ControlledCommand(activeThread, new SignalCmd(executionId, null, null,null)));

  } catch (ActivitiOptimisticLockingException e) {
    this.exception = e;
  }
  log.fine(getName()+" ends");
}
 
开发者ID:iotsap,项目名称:FiWare-Template-Handler,代码行数:12,代码来源:CompetingJoinTest.java


示例20: run

import org.activiti.engine.ActivitiOptimisticLockingException; //导入依赖的package包/类
public void run() {
  try {
    processEngineConfiguration
      .getCommandExecutor()
      .execute(new ControlledCommand(activeThread, new SignalCmd(executionId, null, null,null)));

  } catch (ActivitiOptimisticLockingException e) {
    this.exception = e;
  }
  log.debug("{} ends", getName());
}
 
开发者ID:springvelocity,项目名称:xbpm5,代码行数:12,代码来源:CompetingJoinTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MethodReturn类代码示例发布时间:2022-05-22
下一篇:
Java DateProperty类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap