Exemplo n.º 1
0
        public virtual void testCompetingJobExecutionDeleteJobDuringExecution()
        {
            //given a simple process with a async service task
            //testRule.Deploy(Model.Bpmn.Bpmn.CreateExecutableProcess("process").StartEvent().ServiceTask("task").CamundaAsyncBefore().CamundaDelegateExpression().CamundaExpression("${true}").EndEvent().Done());
            var task = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("process").StartEvent().ServiceTask("task");

            task.CamundaAsyncBefore();
            var r = task.CamundaDelegateExpression(string.Empty).CamundaExpression("${true}").EndEvent().Done();

            testRule.Deploy(r);
            runtimeService.StartProcessInstanceByKey("process");
            IJob currentJob = managementService.CreateJobQuery().First();

            // when a job is executed
            JobExecutionThread threadOne = new JobExecutionThread(this, currentJob.Id);

            threadOne.startAndWaitUntilControlIsReturned();
            //and deleted in parallel
            managementService.DeleteJob(currentJob.Id);

            // then the job fails with a OLE and the failed job listener throws no NPE
            Debug.WriteLine("test thread notifies thread 1");
            threadOne.proceedAndWaitTillDone();
            Assert.True(threadOne.exception is OptimisticLockingException);
        }
Exemplo n.º 2
0
        public virtual void testCompletingUpdateJobDefinitionPriorityDuringExecution()
        {
            testRule.Deploy(SIMPLE_ASYNC_PROCESS);

            // given
            // two running instances
            runtimeService.StartProcessInstanceByKey("simpleAsyncProcess");
            runtimeService.StartProcessInstanceByKey("simpleAsyncProcess");

            // and a job definition
            IJobDefinition jobDefinition = managementService.CreateJobDefinitionQuery().First();

            // and two jobs
            IList <IJob> jobs = managementService.CreateJobQuery().ToList();

            // when the first job is executed but has not yet committed
            JobExecutionThread executionThread = new JobExecutionThread(this, jobs[0].Id);

            executionThread.startAndWaitUntilControlIsReturned();

            // and the job priority is updated
            JobDefinitionPriorityThread priorityThread = new JobDefinitionPriorityThread(this, jobDefinition.Id, 42L, true);

            priorityThread.startAndWaitUntilControlIsReturned();

            // and the priority threads commits first
            priorityThread.proceedAndWaitTillDone();

            // then both jobs priority has changed
            IList <IJob> currentJobs = managementService.CreateJobQuery().ToList();

            foreach (IJob job in currentJobs)
            {
                Assert.AreEqual(42, job.Priority);
            }

            // and the execution thread can nevertheless successfully finish job execution
            executionThread.proceedAndWaitTillDone();

            Assert.IsNull(executionThread.exception);

            // and ultimately only one job with an updated priority is left
            IJob remainingJob = managementService.CreateJobQuery().First();

            Assert.NotNull(remainingJob);
        }
Exemplo n.º 3
0
        public virtual void testCompetingJobExecutionFoxRetryStrategy()
        {
            // given an MI subprocess with two instances
            runtimeService.StartProcessInstanceByKey("miParallelSubprocess");

            IList <IJob> currentJobs = managementService.CreateJobQuery().ToList();

            Assert.AreEqual(2, currentJobs.Count);

            // when the jobs are executed in parallel
            JobExecutionThread threadOne = new JobExecutionThread(this, currentJobs[0].Id);

            threadOne.startAndWaitUntilControlIsReturned();

            JobExecutionThread threadTwo = new JobExecutionThread(this, currentJobs[1].Id);

            threadTwo.startAndWaitUntilControlIsReturned();

            // then the first committing thread succeeds
            Debug.WriteLine("test thread notifies thread 1");
            threadOne.proceedAndWaitTillDone();
            Assert.IsNull(threadOne.exception);

            // then the second committing thread fails with an OptimisticLockingException
            // and the job retries have not been decremented
            Debug.WriteLine("test thread notifies thread 2");
            threadTwo.proceedAndWaitTillDone();
            Assert.NotNull(threadTwo.exception);

            IJob remainingJob = managementService.CreateJobQuery().First();

            // retries are configured as R5/PT5M, so no decrement means 5 retries left
            Assert.AreEqual(5, remainingJob.Retries);

            Assert.NotNull(remainingJob.ExceptionMessage);

            JobEntity jobEntity = (JobEntity)remainingJob;

            Assert.IsNull(jobEntity.LockOwner);

            // and there is a custom lock expiration time
            Assert.NotNull(jobEntity.LockExpirationTime);
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testCompetingJobExecutionDeleteJobDuringExecution()
        public virtual void testCompetingJobExecutionDeleteJobDuringExecution()
        {
            //given a simple process with a async service task
            testRule.deploy(Bpmn.createExecutableProcess("process").startEvent().serviceTask("task").camundaAsyncBefore().camundaExpression("${true}").endEvent().done());
            runtimeService.startProcessInstanceByKey("process");
            Job currentJob = managementService.createJobQuery().singleResult();

            // when a job is executed
            JobExecutionThread threadOne = new JobExecutionThread(this, currentJob.Id);

            threadOne.startAndWaitUntilControlIsReturned();
            //and deleted in parallel
            managementService.deleteJob(currentJob.Id);

            // then the job fails with a OLE and the failed job listener throws no NPE
            LOG.debug("test thread notifies thread 1");
            threadOne.proceedAndWaitTillDone();
            assertTrue(threadOne.exception is OptimisticLockingException);
        }
Exemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test @Deployment public void testCompetingJobExecutionDefaultRetryStrategy()
        public virtual void testCompetingJobExecutionDefaultRetryStrategy()
        {
            // given an MI subprocess with two instances
            runtimeService.startProcessInstanceByKey("miParallelSubprocess");

            IList <Job> currentJobs = managementService.createJobQuery().list();

            assertEquals(2, currentJobs.Count);

            // when the jobs are executed in parallel
            JobExecutionThread threadOne = new JobExecutionThread(this, currentJobs[0].Id);

            threadOne.startAndWaitUntilControlIsReturned();

            JobExecutionThread threadTwo = new JobExecutionThread(this, currentJobs[1].Id);

            threadTwo.startAndWaitUntilControlIsReturned();

            // then the first committing thread succeeds
            LOG.debug("test thread notifies thread 1");
            threadOne.proceedAndWaitTillDone();
            assertNull(threadOne.exception);

            // then the second committing thread fails with an OptimisticLockingException
            // and the job retries have not been decremented
            LOG.debug("test thread notifies thread 2");
            threadTwo.proceedAndWaitTillDone();
            assertNotNull(threadTwo.exception);

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

            assertEquals(currentJobs[1].Retries, remainingJob.Retries);

            assertNotNull(remainingJob.ExceptionMessage);

            JobEntity jobEntity = (JobEntity)remainingJob;

            assertNull(jobEntity.LockOwner);

            // and there is no lock expiration time due to the default retry strategy
            assertNull(jobEntity.LockExpirationTime);
        }
Exemplo n.º 6
0
        public virtual void testCompletingJobExecutionSuspendDuringExecution()
        {
            testRule.Deploy(SIMPLE_ASYNC_PROCESS);

            runtimeService.StartProcessInstanceByKey("simpleAsyncProcess");
            IJob job = managementService.CreateJobQuery().First();

            // given a waiting execution and a waiting suspension
            JobExecutionThread executionthread = new JobExecutionThread(this, job.Id);

            executionthread.startAndWaitUntilControlIsReturned();

            JobSuspensionThread jobSuspensionThread = new JobSuspensionThread(this, "simpleAsyncProcess");

            jobSuspensionThread.startAndWaitUntilControlIsReturned();

            // first complete suspension:
            jobSuspensionThread.proceedAndWaitTillDone();
            executionthread.proceedAndWaitTillDone();

            // then the execution will Assert.Fail with optimistic locking
            Assert.IsNull(jobSuspensionThread.exception);
            Assert.NotNull(executionthread.exception);

            //--------------------------------------------

            // given a waiting execution and a waiting suspension
            executionthread = new JobExecutionThread(this, job.Id);
            executionthread.startAndWaitUntilControlIsReturned();

            jobSuspensionThread = new JobSuspensionThread(this, "simpleAsyncProcess");
            jobSuspensionThread.startAndWaitUntilControlIsReturned();

            // first complete execution:
            executionthread.proceedAndWaitTillDone();
            jobSuspensionThread.proceedAndWaitTillDone();

            // then there are no optimistic locking exceptions
            Assert.IsNull(jobSuspensionThread.exception);
            Assert.IsNull(executionthread.exception);
        }