Package org.activiti.engine.runtime

Examples of org.activiti.engine.runtime.Job


    ProcessDefinition pd = repositoryService.createProcessDefinitionQuery().singleResult();   
    ProcessInstance pi = runtimeService.startProcessInstanceByKey(pd.getKey());
   
    // now there is one job:
    // now there is one job:
    Job job = managementService.createJobQuery().singleResult();
    assertNotNull(job);
   
    makeSureJobDue(job);
   
    // the acquirejobs command sees the job:
View Full Code Here


  public void testJobsNotVisisbleToAcquisitionIfDefinitionSuspended() {
   
    ProcessDefinition pd = repositoryService.createProcessDefinitionQuery().singleResult();   
    runtimeService.startProcessInstanceByKey(pd.getKey());   
    // now there is one job:
    Job job = managementService.createJobQuery()
      .singleResult();
    assertNotNull(job);
   
    makeSureJobDue(job);
       
View Full Code Here

    //Assert that the process instance is active.
    Execution executionJava = runtimeService.createExecutionQuery().processInstanceId(instanceJava.getProcessInstanceId()).singleResult();
    assertFalse(executionJava.isEnded());
   
    // Try to execute job 3 times
    Job jobJava = managementService.createJobQuery().processInstanceId(instanceJava.getId()).singleResult();
    assertNotNull(jobJava);
   
    try {
      managementService.executeJob(jobJava.getId());
      fail("Expected exception");
    } catch (Exception e) {
      // expected
    }
   
    try {
      managementService.executeJob(jobJava.getId());
      fail("Expected exception");
    } catch (Exception e) {
      // expected
    }
   
    try {
      managementService.executeJob(jobJava.getId());
      fail("Expected exception");
    } catch (Exception e) {
      // expected
    }
       
    //Assert that there is a failed job.
    jobJava = managementService.createJobQuery().processInstanceId(instanceJava.getId()).singleResult();
    assertNotNull(jobJava);
    assertEquals(0, jobJava.getRetries());
   
    //Delete the process instance.
    runtimeService.deleteProcessInstance(instanceJava.getId(), null);
   
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
View Full Code Here

*/
public class FailedJobRetryCmdTest extends PluggableActivitiTestCase{
 
  private void waitForExecutedJobWithRetriesLeft(final int retriesLeft) {

      Job job = managementService.createJobQuery().singleResult();

      try {
        managementService.executeJob(job.getId());
      } catch (Exception e) {}

      // update job
      job = managementService.createJobQuery().singleResult();

      if (job.getRetries() > retriesLeft) {
        waitForExecutedJobWithRetriesLeft(retriesLeft);
      }
    }
View Full Code Here

      assertNotNull(pi);
      waitForExecutedJobWithRetriesLeft(4);
     
      stillOneJobWithExceptionAndRetriesLeft();
      
       Job job = fetchJob(pi.getProcessInstanceId());
          assertNotNull(job);
          assertEquals(pi.getProcessInstanceId(), job.getProcessInstanceId());

          assertEquals(4, job.getRetries());

          ExecutionEntity execution = fetchExecutionEntity(pi.getProcessInstanceId());
          assertEquals("failingServiceTask", execution.getActivityId());

          waitForExecutedJobWithRetriesLeft(3);

          job = refreshJob(job.getId());
          assertEquals(3, job.getRetries());
          stillOneJobWithExceptionAndRetriesLeft();

          execution = refreshExecutionEntity(execution.getId());
          assertEquals("failingServiceTask", execution.getActivityId());

          waitForExecutedJobWithRetriesLeft(2);

          job = refreshJob(job.getId());
          assertEquals(2, job.getRetries());
          stillOneJobWithExceptionAndRetriesLeft();

          execution = refreshExecutionEntity(execution.getId());
          assertEquals("failingServiceTask", execution.getActivityId());

          waitForExecutedJobWithRetriesLeft(1);

          job = refreshJob(job.getId());
          assertEquals(1, job.getRetries());
          stillOneJobWithExceptionAndRetriesLeft();

          execution = refreshExecutionEntity(execution.getId());
          assertEquals("failingServiceTask", execution.getActivityId());

          waitForExecutedJobWithRetriesLeft(0);

          job = refreshJob(job.getId());
          assertEquals(0, job.getRetries());
          assertEquals(1, managementService.createJobQuery().withException().count());
          assertEquals(0, managementService.createJobQuery().withRetriesLeft().count());
          assertEquals(1, managementService.createJobQuery().noRetriesLeft().count());

          execution = refreshExecutionEntity(execution.getId());
View Full Code Here

  }

  @Deployment(resources = "org/activiti/engine/test/api/event/JobEventsTest.testJobEntityEvents.bpmn20.xml")
  public void testActivityTimeOutEvent(){
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testJobEvents");
    Job theJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(theJob);

    // Force timer to fire
    Calendar tomorrow = Calendar.getInstance();
    tomorrow.add(Calendar.DAY_OF_YEAR, 1);
View Full Code Here

  }

  @Deployment(resources = "org/activiti/engine/test/bpmn/event/timer/BoundaryTimerEventTest.testTimerOnNestingOfSubprocesses.bpmn20.xml")
  public void testActivityTimeOutEventInSubProcess() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("timerOnNestedSubprocesses");
    Job theJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(theJob);

    // Force timer to fire
    Calendar timeToFire = Calendar.getInstance();
    timeToFire.add(Calendar.HOUR, 2);
View Full Code Here

  }

  @Deployment
  public void testActivityTimeOutEventInCallActivity() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("timerOnCallActivity");
    Job theJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(theJob);

    // Force timer to fire
    Calendar timeToFire = Calendar.getInstance();
    timeToFire.add(Calendar.HOUR, 2);
View Full Code Here

        commandContext.getJobEntityManager().send(message);
        return message.getId();
      }
    });

    Job job = managementService.createJobQuery().singleResult();
    assertEquals(3, job.getRetries());
   
    try {
      managementService.executeJob(job.getId());
      fail("exception expected");
    } catch (Exception e) {
      // exception expected;
    }
   
    job = managementService.createJobQuery().singleResult();
    assertEquals(2, job.getRetries());
   
    try {
      managementService.executeJob(job.getId());
      fail("exception expected");
    } catch (Exception e) {
      // exception expected;
    }
   
    job = managementService.createJobQuery().singleResult();
    assertEquals(1, job.getRetries());
   
    managementService.executeJob(job.getId());
  }
View Full Code Here

   * Test create, update and delete events of jobs entities.
   */
  @Deployment
  public void testJobEntityEvents() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testJobEvents");
    Job theJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(theJob);
   
    // Check if create-event has been dispatched
    assertEquals(2, listener.getEventsReceived().size());
    ActivitiEvent event = listener.getEventsReceived().get(0);
    assertEquals(ActivitiEventType.ENTITY_CREATED, event.getType());
    checkEventContext(event, theJob, false);
   
    event = listener.getEventsReceived().get(1);
    assertEquals(ActivitiEventType.ENTITY_INITIALIZED, event.getType());
    checkEventContext(event, theJob, false);
   
    listener.clearEventsReceived();

    // Update the job-entity. Check if update event is dispatched with update job entity
    managementService.setJobRetries(theJob.getId(), 5);
    assertEquals(1, listener.getEventsReceived().size());
    event = listener.getEventsReceived().get(0);
    assertEquals(ActivitiEventType.ENTITY_UPDATED, event.getType());
    Job updatedJob = (Job) ((ActivitiEntityEvent) event).getEntity();
    assertEquals(5, updatedJob.getRetries());
    checkEventContext(event, theJob, true);
   
    listener.clearEventsReceived();
   
    // Force timer to fire
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.