Package org.activiti.engine.runtime

Examples of org.activiti.engine.runtime.Job


  }

  @Deployment(resources = { "org/activiti/engine/test/api/mgmt/timerOnTask.bpmn20.xml" })
  public void testDeleteJobDeletion() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("timerOnTask");
    Job timerJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();

    assertNotNull("Task timer should be there", timerJob);
    managementService.deleteJob(timerJob.getId());
   
    timerJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNull("There should be no job now. It was deleted", timerJob);
  }
View Full Code Here


  @Deployment(resources = { "org/activiti/engine/test/api/mgmt/timerOnTask.bpmn20.xml" })
  public void testDeleteJobThatWasAlreadyAcquired() {
    processEngineConfiguration.getClock().setCurrentTime(new Date());
   
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("timerOnTask");
    Job timerJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
   
    // We need to move time at least one hour to make the timer executable
    processEngineConfiguration.getClock().setCurrentTime(new Date(processEngineConfiguration.getClock().getCurrentTime().getTime() + 7200000L));

    // Acquire job by running the acquire command manually
    ProcessEngineImpl processEngineImpl = (ProcessEngineImpl) processEngine;
    AcquireTimerJobsCmd acquireJobsCmd = new AcquireTimerJobsCmd("testLockOwner", 60000, 5);
    CommandExecutor commandExecutor = processEngineImpl.getProcessEngineConfiguration().getCommandExecutor();
    commandExecutor.execute(acquireJobsCmd);
   
    // Try to delete the job. This should fail.
    try {
      managementService.deleteJob(timerJob.getId());
      fail();
    } catch (ActivitiException e) {
      // Exception is expected
    }
   
    // Clean up
    managementService.executeJob(timerJob.getId());
  }
View Full Code Here

  @Autowired
  protected ManagementService managementService;

  @RequestMapping(value="/management/jobs/{jobId}/exception-stacktrace", method = RequestMethod.GET)
  public String getJobStacktrace(@PathVariable String jobId, HttpServletResponse response) {
    Job job = getJobFromResponse(jobId);
   
    String stackTrace = managementService.getJobExceptionStacktrace(job.getId());
   
    if (stackTrace == null) {
      throw new ActivitiObjectNotFoundException("Job with id '" + job.getId() + "' doesn't have an exception stacktrace.", String.class);
    }
   
    response.setContentType("text/plain");
    return stackTrace;
  }
View Full Code Here

    return stackTrace;
  }

 
  protected Job getJobFromResponse(String jobId) {
    Job job = managementService.createJobQuery().jobId(jobId).singleResult();

    if (job == null) {
      throw new ActivitiObjectNotFoundException("Could not find a job with id '" + jobId + "'.", Job.class);
    }
    return job;
View Full Code Here

  @Autowired
  protected ManagementService managementService;

  @RequestMapping(value="/management/jobs/{jobId}", method = RequestMethod.GET, produces = "application/json")
  public JobResponse getJob(@PathVariable String jobId, HttpServletRequest request) {
    Job job = getJobFromResponse(jobId);
   
    String serverRootUrl = request.getRequestURL().toString();
    serverRootUrl = serverRootUrl.substring(0, serverRootUrl.indexOf("/management/jobs/"));
    JobResponse response = restResponseFactory.createJobResponse(job, serverRootUrl);
    return response;
View Full Code Here

   
    response.setStatus(HttpStatus.NO_CONTENT.value());
  }

  protected Job getJobFromResponse(String jobId) {
    Job job = managementService.createJobQuery().jobId(jobId).singleResult();

    if (job == null) {
      throw new ActivitiObjectNotFoundException("Could not find a job with id '" + jobId + "'.", Job.class);
    }
    return job;
View Full Code Here

      fail();
    } catch (ActivitiIllegalArgumentException e) {}
  }
 
  public void testQueryByExecutionId() {
    Job job = managementService.createJobQuery().processInstanceId(processInstanceIdOne).singleResult();
    JobQuery query = managementService.createJobQuery().executionId(job.getExecutionId());
    assertEquals(query.singleResult().getId(), job.getId());
    verifyQueryResults(query, 1);
  }
View Full Code Here

 
  public void testJobQueryWithExceptions() throws Throwable {
   
    createJobWithoutExceptionMsg();
   
    Job job = managementService.createJobQuery().jobId(timerEntity.getId()).singleResult();
   
    assertNotNull(job);
   
    List<Job> list = managementService.createJobQuery().withException().list();
    assertEquals(list.size(), 1);
View Full Code Here

  }
 
  //helper ////////////////////////////////////////////////////////////
 
  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

    // start a process with a failing job
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("exceptionInJobExecution");
   
    // The execution is waiting in the first usertask. This contains a boundary
    // timer event which we will execute manual for testing purposes.
    Job timerJob = managementService.createJobQuery()
      .processInstanceId(processInstance.getId())
      .singleResult();
   
    assertNotNull("No job found for process instance", timerJob);
   
    try {
      managementService.executeJob(timerJob.getId());
      fail("RuntimeException from within the script task expected");
    } catch(RuntimeException re) {
      assertTextPresent(EXCEPTION_MESSAGE, re.getCause().getMessage());
    }
    return processInstance;
View Full Code Here

TOP

Related Classes of org.activiti.engine.runtime.Job

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.