Search in sources :

Example 6 with AcquireJobsCmd

use of org.camunda.bpm.engine.impl.cmd.AcquireJobsCmd in project camunda-bpm-platform by camunda.

the class IndependentJobExecutionTest method testDeploymentUnawareJobAcquisition.

@OperateOnDeployment("pa1")
@Test
public void testDeploymentUnawareJobAcquisition() {
    JobExecutor defaultJobExecutor = processEngineConfiguration.getJobExecutor();
    ProcessInstance instance1 = engine1.getRuntimeService().startProcessInstanceByKey("archive1Process");
    ProcessInstance instance2 = processEngine.getRuntimeService().startProcessInstanceByKey("archive2Process");
    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 {
        processEngineConfiguration.setJobExecutorDeploymentAware(true);
    }
}
Also used : AcquireJobsCmd(org.camunda.bpm.engine.impl.cmd.AcquireJobsCmd) JobExecutor(org.camunda.bpm.engine.impl.jobexecutor.JobExecutor) CommandExecutor(org.camunda.bpm.engine.impl.interceptor.CommandExecutor) AcquiredJobs(org.camunda.bpm.engine.impl.jobexecutor.AcquiredJobs) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Job(org.camunda.bpm.engine.runtime.Job) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) AbstractFoxPlatformIntegrationTest(org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest) Test(org.junit.Test)

Aggregations

AcquireJobsCmd (org.camunda.bpm.engine.impl.cmd.AcquireJobsCmd)6 JobExecutor (org.camunda.bpm.engine.impl.jobexecutor.JobExecutor)6 CommandExecutor (org.camunda.bpm.engine.impl.interceptor.CommandExecutor)5 AcquiredJobs (org.camunda.bpm.engine.impl.jobexecutor.AcquiredJobs)4 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)3 Job (org.camunda.bpm.engine.runtime.Job)3 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 List (java.util.List)2 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)2 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)2 Test (org.junit.Test)2 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 ProcessEngineImpl (org.camunda.bpm.engine.impl.ProcessEngineImpl)1 DbEntityManager (org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager)1 JobManager (org.camunda.bpm.engine.impl.persistence.entity.JobManager)1 MessageEntity (org.camunda.bpm.engine.impl.persistence.entity.MessageEntity)1 TimerEntity (org.camunda.bpm.engine.impl.persistence.entity.TimerEntity)1 Deployment (org.camunda.bpm.engine.test.Deployment)1