Package org.camunda.bpm.engine.impl.interceptor

Examples of org.camunda.bpm.engine.impl.interceptor.CommandExecutor


    Job job1 = managementService.createJobQuery().processInstanceId(instance1.getId()).singleResult();
    Job job2 = managementService.createJobQuery().processInstanceId(instance2.getId()).singleResult();

    // the deployment unaware configuration should return both jobs
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
    processEngineConfiguration.setJobExecutorDeploymentAware(false);
    try {
      AcquiredJobs acquiredJobs = commandExecutor.execute(new AcquireJobsCmd(defaultJobExecutor));

      Assert.assertEquals(2, acquiredJobs.size());
      Assert.assertTrue(acquiredJobs.contains(job1.getId()));
      Assert.assertTrue(acquiredJobs.contains(job2.getId()));
    } finally {
View Full Code Here


    final ExceptionThrowingCmd innerCommand2 = new ExceptionThrowingCmd(new IdentifiableRuntimeException(2));

    try {
      processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<Object>() {
        public Object execute(CommandContext commandContext) {
          CommandExecutor commandExecutor = Context.getProcessEngineConfiguration().getCommandExecutorTxRequired();

          commandExecutor.execute(innerCommand1);
          commandExecutor.execute(innerCommand2);

          return null;
        }
      });
View Full Code Here

  public void testCommandContextNestedTryCatch() {
    final ExceptionThrowingCmd innerCommand = new ExceptionThrowingCmd(new IdentifiableRuntimeException(1));

    processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<Object>() {
      public Object execute(CommandContext commandContext) {
        CommandExecutor commandExecutor = Context.getProcessEngineConfiguration().getCommandExecutorTxRequired();

        try {
          commandExecutor.execute(innerCommand);
          fail("exception expected to pop up during execution of inner command");
        } catch (IdentifiableRuntimeException e) {
          // happy path
          assertNull("the exception should not have been propagated to this command's context",
              Context.getCommandInvocationContext().getThrowable());
View Full Code Here

    public Void execute(CommandContext commandContext) {
      assertEquals(this, Context.getCommandInvocationContext().getCommand());

      if (innerCommand != null) {
        CommandExecutor commandExecutor = Context.getProcessEngineConfiguration().getCommandExecutorTxRequired();
        commandExecutor.execute(innerCommand);

        // should still be correct after command invocation
        assertEquals(this, Context.getCommandInvocationContext().getCommand());
      }
View Full Code Here

    if (log.isLoggable(Level.FINE)) {
      log.fine("Executing job " + jobId);
    }
    JobEntity job = commandContext.getDbEntityManager().selectById(JobEntity.class, jobId);

    final CommandExecutor commandExecutor = Context.getProcessEngineConfiguration().getCommandExecutorTxRequiresNew();
    final JobExecutorContext jobExecutorContext = Context.getJobExecutorContext();

    if (job == null) {

      if (jobExecutorContext != null) {
View Full Code Here

    LogUtil.readJavaUtilLoggingConfigFromClasspath();
  }

  public static void main(String[] args) {
    ProcessEngineImpl processEngine = (ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine();
    CommandExecutor commandExecutor = processEngine.getProcessEngineConfiguration().getCommandExecutorTxRequired();
    commandExecutor.execute(new Command<Object> (){
      public Object execute(CommandContext commandContext) {
        commandContext
          .getSession(PersistenceSession.class)
          .dbSchemaPrune();
        return null;
View Full Code Here

    timer.setLockExpirationTime(null);
    timer.setJobHandlerType(TimerStartEventJobHandler.TYPE);
    timer.setJobHandlerConfiguration(myCustomTimerEntity);
    timer.setProcessInstanceId(processInstanceId);

    final CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();

    try {
      // we create a timer entity
      commandExecutor.execute(new Command<Void>() {
        public Void execute(CommandContext commandContext) {
          commandContext.getJobManager().insert(timer);
          return null;
        }
      });

      // we change the suspension state to null
      commandExecutor.execute(new Command<Void>() {
        public Void execute(CommandContext commandContext) {
          Connection connection = null;
          Statement statement = null;
          ResultSet rs = null;

          try {
            SqlSession sqlSession = commandContext.getDbSqlSession().getSqlSession();
            connection = sqlSession.getConnection();
            statement = connection
                .createStatement();
            int updateResult = statement.executeUpdate("UPDATE ACT_RU_JOB " +
                "SET SUSPENSION_STATE_ = NULL, REV_ = 2" +
                " WHERE SUSPENSION_STATE_ = 1");
            statement.close();
            assertEquals(1, updateResult);

            statement = connection
                .createStatement();
            rs = statement.executeQuery("SELECT * FROM ACT_RU_JOB WHERE SUSPENSION_STATE_ IS NULL");

            int rowNum = 0;
            while (rs.next()) {
              rowNum = rs.getRow();
            }
            assertEquals(1, rowNum);
          } catch (SQLException e) {
            throw new RuntimeException(e);
          } finally {
            try {
              if (statement != null) {
                statement.close();
              }
              if (rs != null) {
                rs.close();
              }
              if (connection != null) {
                connection.close();
              }
            } catch (SQLException e) {
              throw new RuntimeException(e);
            }
          }
          return null;
        }
      });

      // it is picked up by the acquisition queries
      commandExecutor.execute(new Command<Void>() {
        public Void execute(CommandContext commandContext) {
          JobManager jobManager = commandContext.getJobManager();

          List<JobEntity> executableJobs = jobManager.findNextJobsToExecute(new Page(0, 1));

          assertEquals(1, executableJobs.size());
          assertEquals(myCustomTimerEntity, executableJobs.get(0).getJobHandlerConfiguration());

          executableJobs = jobManager.findExclusiveJobsToExecute(processInstanceId);
          assertEquals(1, executableJobs.size());
          assertEquals(myCustomTimerEntity, executableJobs.get(0).getJobHandlerConfiguration());
          return null;
        }
      });

    } finally {
      // cleanup
      commandExecutor.execute(new Command<Void>() {
        public Void execute(CommandContext commandContext) {
          final JobEntity newTimer = commandContext.getJobManager().findJobById(timer.getId());
          newTimer.delete();
          return null;
        }
View Full Code Here

    deleteJobAndIncidents(job);
  }

  protected void createJob(final int retries, final String owner, final Date lockExpirationTime) {
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
    commandExecutor.execute(new Command<Void>() {
      public Void execute(CommandContext commandContext) {
        JobManager jobManager = commandContext.getJobManager();
        MessageEntity job = new MessageEntity();
        job.setJobHandlerType("any");
        job.setLockOwner(owner);
View Full Code Here

  public void testSetJobRetriesByDefinitionUnlocksInconsistentJobs() {
    // given a job definition
    final JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult();

    // and an inconsistent job that is never again picked up by a job executor
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
    commandExecutor.execute(new Command<Void>() {
      public Void execute(CommandContext commandContext) {
        JobManager jobManager = commandContext.getJobManager();
        MessageEntity job = new MessageEntity();
        job.setJobDefinitionId(jobDefinition.getId());
        job.setJobHandlerType("any");
View Full Code Here

  protected void deleteJobAndIncidents(final Job job) {
    final List<HistoricIncident> incidents =
        historyService.createHistoricIncidentQuery()
        .incidentType(FailedJobIncidentHandler.INCIDENT_HANDLER_TYPE).list();

    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
    commandExecutor.execute(new Command<Void>() {
      public Void execute(CommandContext commandContext) {
        ((JobEntity) job).delete();

        HistoricIncidentManager historicIncidentManager = commandContext.getHistoricIncidentManager();
        for (HistoricIncident incident : incidents) {
View Full Code Here

TOP

Related Classes of org.camunda.bpm.engine.impl.interceptor.CommandExecutor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.