Search in sources :

Example 11 with JobExecutor

use of org.camunda.bpm.engine.impl.jobexecutor.JobExecutor in project camunda-bpm-platform by camunda.

the class TestJobExecutorActivateFalse_JBOSS method shouldNotActiateJobExecutor.

@Test
public void shouldNotActiateJobExecutor() {
    ProcessEngine processEngine = processEngineService.getProcessEngine("jobExecutorActivate-FALSE-engine");
    ProcessEngineConfiguration configuration = processEngine.getProcessEngineConfiguration();
    JobExecutor jobExecutor = ((ProcessEngineConfigurationImpl) configuration).getJobExecutor();
    assertFalse(jobExecutor.isActive());
    processEngine = processEngineService.getProcessEngine("jobExecutorActivate-UNDEFINED-engine");
    configuration = processEngine.getProcessEngineConfiguration();
    jobExecutor = ((ProcessEngineConfigurationImpl) configuration).getJobExecutor();
    assertTrue(jobExecutor.isActive());
}
Also used : ProcessEngineConfiguration(org.camunda.bpm.engine.ProcessEngineConfiguration) JobExecutor(org.camunda.bpm.engine.impl.jobexecutor.JobExecutor) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) AbstractFoxPlatformIntegrationTest(org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest) Test(org.junit.Test)

Example 12 with JobExecutor

use of org.camunda.bpm.engine.impl.jobexecutor.JobExecutor in project camunda-bpm-platform by camunda.

the class CdiProcessEngineTestCase method waitForJobExecutorOnCondition.

public void waitForJobExecutorOnCondition(long maxMillisToWait, long intervalMillis, Callable<Boolean> condition) {
    JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();
    jobExecutor.start();
    try {
        Timer timer = new Timer();
        InteruptTask task = new InteruptTask(Thread.currentThread());
        timer.schedule(task, maxMillisToWait);
        boolean conditionIsViolated = true;
        try {
            while (conditionIsViolated) {
                Thread.sleep(intervalMillis);
                conditionIsViolated = !condition.call();
            }
        } catch (InterruptedException e) {
        } catch (Exception e) {
            throw new ProcessEngineException("Exception while waiting on condition: " + e.getMessage(), e);
        } finally {
            timer.cancel();
        }
        if (conditionIsViolated) {
            throw new ProcessEngineException("time limit of " + maxMillisToWait + " was exceeded");
        }
    } finally {
        jobExecutor.shutdown();
    }
}
Also used : Timer(java.util.Timer) JobExecutor(org.camunda.bpm.engine.impl.jobexecutor.JobExecutor) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 13 with JobExecutor

use of org.camunda.bpm.engine.impl.jobexecutor.JobExecutor in project camunda-bpm-platform by camunda.

the class StartJobAcquisitionStep method performOperationStep.

public void performOperationStep(DeploymentOperation operationContext) {
    final PlatformServiceContainer serviceContainer = operationContext.getServiceContainer();
    final AbstractProcessApplication processApplication = operationContext.getAttachment(PROCESS_APPLICATION);
    ClassLoader configurationClassloader = null;
    if (processApplication != null) {
        configurationClassloader = processApplication.getProcessApplicationClassloader();
    } else {
        configurationClassloader = ProcessEngineConfiguration.class.getClassLoader();
    }
    String configurationClassName = jobAcquisitionXml.getJobExecutorClassName();
    if (configurationClassName == null || configurationClassName.isEmpty()) {
        configurationClassName = RuntimeContainerJobExecutor.class.getName();
    }
    // create & instantiate the job executor class
    Class<? extends JobExecutor> jobExecutorClass = loadJobExecutorClass(configurationClassloader, configurationClassName);
    JobExecutor jobExecutor = instantiateJobExecutor(jobExecutorClass);
    // apply properties
    Map<String, String> properties = jobAcquisitionXml.getProperties();
    PropertyHelper.applyProperties(jobExecutor, properties);
    // construct service for job executor
    JmxManagedJobExecutor jmxManagedJobExecutor = new JmxManagedJobExecutor(jobExecutor);
    // deploy the job executor service into the container
    serviceContainer.startService(ServiceTypes.JOB_EXECUTOR, jobAcquisitionXml.getName(), jmxManagedJobExecutor);
}
Also used : JmxManagedJobExecutor(org.camunda.bpm.container.impl.jmx.services.JmxManagedJobExecutor) AbstractProcessApplication(org.camunda.bpm.application.AbstractProcessApplication) ProcessEngineConfiguration(org.camunda.bpm.engine.ProcessEngineConfiguration) PlatformServiceContainer(org.camunda.bpm.container.impl.spi.PlatformServiceContainer) JobExecutor(org.camunda.bpm.engine.impl.jobexecutor.JobExecutor) JmxManagedJobExecutor(org.camunda.bpm.container.impl.jmx.services.JmxManagedJobExecutor) RuntimeContainerJobExecutor(org.camunda.bpm.engine.impl.jobexecutor.RuntimeContainerJobExecutor) RuntimeContainerJobExecutor(org.camunda.bpm.engine.impl.jobexecutor.RuntimeContainerJobExecutor)

Example 14 with JobExecutor

use of org.camunda.bpm.engine.impl.jobexecutor.JobExecutor in project camunda-bpm-platform by camunda.

the class StartProcessEngineStep method getJobExecutorService.

protected JobExecutor getJobExecutorService(final PlatformServiceContainer serviceContainer) {
    // lookup container managed job executor
    String jobAcquisitionName = processEngineXml.getJobAcquisitionName();
    JobExecutor jobExecutor = serviceContainer.getServiceValue(ServiceTypes.JOB_EXECUTOR, jobAcquisitionName);
    return jobExecutor;
}
Also used : JobExecutor(org.camunda.bpm.engine.impl.jobexecutor.JobExecutor)

Example 15 with JobExecutor

use of org.camunda.bpm.engine.impl.jobexecutor.JobExecutor in project camunda-bpm-platform by camunda.

the class TestHelper method waitForJobExecutorToProcessAllJobs.

public static void waitForJobExecutorToProcessAllJobs(ProcessEngineConfigurationImpl processEngineConfiguration, long maxMillisToWait, long intervalMillis) {
    JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();
    jobExecutor.start();
    try {
        Timer timer = new Timer();
        InteruptTask task = new InteruptTask(Thread.currentThread());
        timer.schedule(task, maxMillisToWait);
        boolean areJobsAvailable = true;
        try {
            while (areJobsAvailable && !task.isTimeLimitExceeded()) {
                Thread.sleep(intervalMillis);
                areJobsAvailable = areJobsAvailable(processEngineConfiguration);
            }
        } catch (InterruptedException e) {
        } finally {
            timer.cancel();
        }
        if (areJobsAvailable) {
            throw new ProcessEngineException("time limit of " + maxMillisToWait + " was exceeded");
        }
    } finally {
        jobExecutor.shutdown();
    }
}
Also used : JobExecutor(org.camunda.bpm.engine.impl.jobexecutor.JobExecutor) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Aggregations

JobExecutor (org.camunda.bpm.engine.impl.jobexecutor.JobExecutor)21 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)6 AcquireJobsCmd (org.camunda.bpm.engine.impl.cmd.AcquireJobsCmd)6 Timer (java.util.Timer)5 CommandExecutor (org.camunda.bpm.engine.impl.interceptor.CommandExecutor)5 AcquiredJobs (org.camunda.bpm.engine.impl.jobexecutor.AcquiredJobs)4 Test (org.junit.Test)4 Date (java.util.Date)3 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)3 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 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 AbstractProcessApplication (org.camunda.bpm.application.AbstractProcessApplication)2 PlatformServiceContainer (org.camunda.bpm.container.impl.spi.PlatformServiceContainer)2 ProcessEngineConfiguration (org.camunda.bpm.engine.ProcessEngineConfiguration)2 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)2 HashMap (java.util.HashMap)1