Package org.activiti.engine.impl.persistence.entity

Examples of org.activiti.engine.impl.persistence.entity.JobEntity


            this.waitBetweenRetriesInSeconds = waitBetweenRetriesInSeconds;
        }

        @Override
        public Object execute(CommandContext commandContext) {
            JobEntity job = Context.getCommandContext()
                .getJobManager()
                .findJobById(jobId);

            updateNumberOfRetries(job);

            if (exception != null) {
                job.setExceptionMessage(exception.getMessage());
                job.setExceptionStacktrace(getExceptionStacktrace());
            }

            return null;
        }
View Full Code Here


    this.jobId = jobId;
    this.retries = retries;
  }

  public Void execute(CommandContext commandContext) {
    JobEntity job = commandContext
            .getJobManager()
            .findJobById(jobId);
    if (job != null) {
      job.setRetries(retries);
    } else {
      throw new ActivitiException("No job found with id '" + jobId + "'.");
    }
    return null;
  }
View Full Code Here

    }
    if (log.isLoggable(Level.FINE)) {
      log.fine("Deleting job " + jobId);
    }

    JobEntity job = commandContext.getJobManager().findJobById(jobId);
    if (job == null) {
      throw new ActivitiException("No job found with id '" + jobId + "'");
    }
   
    // We need to check if the job was locked, ie acquired by the job acquisition thread
    // This happens if the the job was already acquired, but not yet executed.
    // In that case, we can't allow to delete the job.
    if (job.getLockOwner() != null || job.getLockExpirationTime() != null)
    {
      throw new ActivitiException("Cannot delete job when the job is being executed. Try again later.");
    }

    job.delete();
    return null;
  }
View Full Code Here

  protected void initJobQueueListener() {
    jobQueueListenerThread = new Thread(new Runnable() {
     
      public void run() {
        while (isActive) {
          JobEntity job = null;
          try {
            job = jobQueue.take(); // Blocking
          } catch (InterruptedException e1) {
            // Do nothing, this can happen when shutting down
          }
View Full Code Here

  private void setRetries(final String processInstanceId, final int retries) {
    final Job job = managementService.createJobQuery().processInstanceId(processInstanceId).singleResult();
    commandExecutor.execute(new Command<Void>() {
     
      public Void execute(CommandContext commandContext) {
        JobEntity timer = commandContext.getDbSqlSession().selectById(JobEntity.class, job.getId());
        timer.setRetries(retries);
        return null;
      }
     
    });
  }
View Full Code Here

    processEngineConfiguration.getClock().setCurrentTime(new Date(SOME_TIME + (20 * SECOND)));

    acquiredJobs = commandExecutor.execute(new AcquireTimerJobsCmd("testLockOwner", 10000, 5));
    assertEquals(1, acquiredJobs.size());

    JobEntity job = acquiredJobs.getJobs().iterator().next();

    assertEquals(jobId, job.getId());

    assertEquals(0, tweetHandler.getMessages().size());

    commandExecutor.execute(new ExecuteAsyncJobCmd(job));

View Full Code Here

    startExecutingAsyncJobs();
   
    isActive = true;
       
    while (temporaryJobQueue.isEmpty() == false) {
      JobEntity job = temporaryJobQueue.pop();
      executeAsyncJob(job);
    }
    isActive = true;
  }
View Full Code Here

    Context.setJobExecutorContext(jobExecutorContext);
    try {
      while (!currentProcessorJobQueue.isEmpty()) {

        JobEntity currentJob = currentProcessorJobQueue.remove(0);
        try {
          commandExecutor.execute(new ExecuteJobsCmd(currentJob));
        } catch (Throwable e) {
          log.error("exception during job execution: {}", e.getMessage(), e);
        } finally {
View Full Code Here

  public DeleteJobCmd(String jobId) {
    this.jobId = jobId;
  }

  public Object execute(CommandContext commandContext) {
    JobEntity jobToDelete = getJobToDelete(commandContext);

    jobToDelete.delete();
    return null;
  }
View Full Code Here

    }
    if (log.isDebugEnabled()) {
      log.debug("Deleting job {}", jobId);
    }

    JobEntity job = commandContext.getJobEntityManager().findJobById(jobId);
    if (job == null) {
      throw new ActivitiObjectNotFoundException("No job found with id '" + jobId + "'", Job.class);
    }

    // We need to check if the job was locked, ie acquired by the job acquisition thread
    // This happens if the the job was already acquired, but not yet executed.
    // In that case, we can't allow to delete the job.
    if (job.getLockOwner() != null) {
      throw new ActivitiException("Cannot delete job when the job is being executed. Try again later.");
    }
    return job;
  }
View Full Code Here

TOP

Related Classes of org.activiti.engine.impl.persistence.entity.JobEntity

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.