org.flowable.job.service.impl.asyncexecutor.AsyncExecutor Java Examples
The following examples show how to use
org.flowable.job.service.impl.asyncexecutor.AsyncExecutor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CdiFlowableTestCase.java From flowable-engine with Apache License 2.0 | 6 votes |
public void waitForJobExecutorToProcessAllJobs(long maxMillisToWait, long intervalMillis) { AsyncExecutor asyncExecutor = processEngineConfiguration.getAsyncExecutor(); asyncExecutor.start(); try { Timer timer = new Timer(); InterruptTask task = new InterruptTask(Thread.currentThread()); timer.schedule(task, maxMillisToWait); boolean areJobsAvailable = true; try { while (areJobsAvailable && !task.isTimeLimitExceeded()) { Thread.sleep(intervalMillis); areJobsAvailable = areJobsAvailable(); } } catch (InterruptedException e) { } finally { timer.cancel(); } if (areJobsAvailable) { throw new FlowableException("time limit of " + maxMillisToWait + " was exceeded"); } } finally { asyncExecutor.shutdown(); } }
Example #2
Source File: CmmnJobTestHelper.java From flowable-engine with Apache License 2.0 | 6 votes |
public static void executeJobExecutorForTime(CmmnEngineConfiguration cmmnEngineConfiguration, long maxMillisToWait, long intervalMillis) { AsyncExecutor asyncExecutor = cmmnEngineConfiguration.getAsyncExecutor(); asyncExecutor.start(); try { Timer timer = new Timer(); InterruptTask task = new InterruptTask(Thread.currentThread()); timer.schedule(task, maxMillisToWait); try { while (!task.isTimeLimitExceeded()) { Thread.sleep(intervalMillis); } } catch (InterruptedException e) { // ignore } finally { timer.cancel(); } } finally { asyncExecutor.shutdown(); } }
Example #3
Source File: JobTestHelper.java From flowable-engine with Apache License 2.0 | 6 votes |
public static void executeJobExecutorForTime(ProcessEngineConfiguration processEngineConfiguration, long maxMillisToWait, long intervalMillis) { AsyncExecutor asyncExecutor = processEngineConfiguration.getAsyncExecutor(); asyncExecutor.start(); try { Timer timer = new Timer(); InterruptTask task = new InterruptTask(Thread.currentThread()); timer.schedule(task, maxMillisToWait); try { while (!task.isTimeLimitExceeded()) { Thread.sleep(intervalMillis); } } catch (InterruptedException e) { // ignore } finally { timer.cancel(); } } finally { asyncExecutor.shutdown(); } }
Example #4
Source File: BaseSpringRestTestCase.java From flowable-engine with Apache License 2.0 | 6 votes |
public void waitForJobExecutorToProcessAllJobs(long maxMillisToWait, long intervalMillis) { AsyncExecutor asyncExecutor = processEngineConfiguration.getAsyncExecutor(); asyncExecutor.start(); try { Timer timer = new Timer(); InterruptTask task = new InterruptTask(Thread.currentThread()); timer.schedule(task, maxMillisToWait); boolean areJobsAvailable = true; try { while (areJobsAvailable && !task.isTimeLimitExceeded()) { Thread.sleep(intervalMillis); areJobsAvailable = areJobsAvailable(); } } catch (InterruptedException e) { } finally { timer.cancel(); } if (areJobsAvailable) { throw new FlowableException("time limit of " + maxMillisToWait + " was exceeded"); } } finally { asyncExecutor.shutdown(); } }
Example #5
Source File: ProcessAndCmmnEngineAsyncExecutorTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void cmmnShouldUseDedicatedAndProcessEngineShouldUsePrimaryRejectedHandler() { contextRunner.withUserConfiguration(CmmnRejectedHandlerConfiguration.class, PrimaryRejectedHandlerConfiguration.class) .run((context -> { AsyncExecutor processAsyncExecutor = context.getBean(ProcessEngine.class).getProcessEngineConfiguration().getAsyncExecutor(); AsyncExecutor cmmnAsyncExecutor = context.getBean(CmmnEngine.class).getCmmnEngineConfiguration().getAsyncExecutor(); assertThat(context) .doesNotHaveBean("springRejectedJobsHandler") .hasBean("cmmnRejectedJobsHandler") .hasBean("primaryRejectedJobsHandler"); SpringRejectedJobsHandler primaryRejectedJobsHandlerBean = context.getBean("primaryRejectedJobsHandler", SpringRejectedJobsHandler.class); SpringRejectedJobsHandler cmmnRejectedJobsHandlerBean = context.getBean("cmmnRejectedJobsHandler", SpringRejectedJobsHandler.class); assertThat(((SpringAsyncExecutor) processAsyncExecutor).getRejectedJobsHandler()) .as("Process Async Rejected Jobs Handler") .isSameAs(primaryRejectedJobsHandlerBean) .isNotSameAs(((SpringAsyncExecutor) cmmnAsyncExecutor).getRejectedJobsHandler()); assertThat(((SpringAsyncExecutor) cmmnAsyncExecutor).getRejectedJobsHandler()) .as("Cmmn Async Rejected Jobs Handler") .isSameAs(cmmnRejectedJobsHandlerBean); })); }
Example #6
Source File: ProcessAndCmmnEngineAsyncExecutorTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void cmmnAndProcessEngineShouldUseDistinctRejectedHandlers() { contextRunner.withUserConfiguration(DedicatedRejectedHandlerConfiguration.class) .run((context -> { AsyncExecutor processAsyncExecutor = context.getBean(ProcessEngine.class).getProcessEngineConfiguration().getAsyncExecutor(); AsyncExecutor cmmnAsyncExecutor = context.getBean(CmmnEngine.class).getCmmnEngineConfiguration().getAsyncExecutor(); assertThat(context) .doesNotHaveBean("springRejectedJobsHandler") .hasBean("cmmnRejectedJobsHandler") .hasBean("processRejectedJobsHandler"); SpringRejectedJobsHandler processRejectedJobsHandlerBean = context.getBean("processRejectedJobsHandler", SpringRejectedJobsHandler.class); SpringRejectedJobsHandler cmmnRejectedJobsHandlerBean = context.getBean("cmmnRejectedJobsHandler", SpringRejectedJobsHandler.class); assertThat(((SpringAsyncExecutor) processAsyncExecutor).getRejectedJobsHandler()) .as("Process Async Rejected Jobs Handler") .isSameAs(processRejectedJobsHandlerBean) .isNotSameAs(((SpringAsyncExecutor) cmmnAsyncExecutor).getRejectedJobsHandler()); assertThat(((SpringAsyncExecutor) cmmnAsyncExecutor).getRejectedJobsHandler()) .as("Cmmn Async Rejected Jobs Handler") .isSameAs(cmmnRejectedJobsHandlerBean); })); }
Example #7
Source File: ProcessAndCmmnEngineAsyncExecutorTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void cmmnShouldUsePrimaryAndProcessEngineShouldUseDedicatedTaskExecutor() { contextRunner.withUserConfiguration(ProcessTaskExecutorConfiguration.class, PrimaryTaskExecutorConfiguration.class) .run((context -> { AsyncExecutor processAsyncExecutor = context.getBean(ProcessEngine.class).getProcessEngineConfiguration().getAsyncExecutor(); AsyncExecutor cmmnAsyncExecutor = context.getBean(CmmnEngine.class).getCmmnEngineConfiguration().getAsyncExecutor(); assertThat(context) .doesNotHaveBean("taskExecutor") .hasBean("primaryTaskExecutor") .hasBean("processTaskExecutor"); TaskExecutor prmiaryTaskExecutorBean = context.getBean("primaryTaskExecutor", TaskExecutor.class); TaskExecutor processTaskExecutorBean = context.getBean("processTaskExecutor", TaskExecutor.class); assertThat(((SpringAsyncExecutor) processAsyncExecutor).getTaskExecutor()) .as("Process Async Task Executor") .isSameAs(processTaskExecutorBean) .isNotSameAs(((SpringAsyncExecutor) cmmnAsyncExecutor).getTaskExecutor()); assertThat(((SpringAsyncExecutor) cmmnAsyncExecutor).getTaskExecutor()) .as("Cmmn Async Task Executor") .isSameAs(prmiaryTaskExecutorBean); })); }
Example #8
Source File: ProcessAndCmmnEngineAsyncExecutorTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void cmmnAndProcessEngineShouldUseDistinctTaskExecutors() { contextRunner.withUserConfiguration(DedicatedTaskExecutorsConfiguration.class) .run((context -> { AsyncExecutor processAsyncExecutor = context.getBean(ProcessEngine.class).getProcessEngineConfiguration().getAsyncExecutor(); AsyncExecutor cmmnAsyncExecutor = context.getBean(CmmnEngine.class).getCmmnEngineConfiguration().getAsyncExecutor(); assertThat(context) .doesNotHaveBean("taskExecutor") .hasBean("cmmnTaskExecutor") .hasBean("processTaskExecutor"); TaskExecutor cmmnTaskExecutorBean = context.getBean("cmmnTaskExecutor", TaskExecutor.class); TaskExecutor processTaskExecutorBean = context.getBean("processTaskExecutor", TaskExecutor.class); assertThat(((SpringAsyncExecutor) processAsyncExecutor).getTaskExecutor()) .as("Process Async Task Executor") .isSameAs(processTaskExecutorBean) .isNotSameAs(((SpringAsyncExecutor) cmmnAsyncExecutor).getTaskExecutor()); assertThat(((SpringAsyncExecutor) cmmnAsyncExecutor).getTaskExecutor()) .as("Cmmn Async Task Executor") .isSameAs(cmmnTaskExecutorBean); })); }
Example #9
Source File: ProcessAsyncHistoryExecutorTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void asyncHistoryExecutorBeanWithDefault() { contextRunner .run((context -> { assertThat(context).doesNotHaveBean("asyncHistoryExecutor"); AsyncExecutor processAsyncHistoryExecutor = context.getBean(ProcessEngine.class).getProcessEngineConfiguration().getAsyncHistoryExecutor(); assertThat(processAsyncHistoryExecutor).isNull(); assertThat(context.getBean(ProcessEngine.class).getProcessEngineConfiguration().isAsyncHistoryExecutorActivate()).isTrue(); assertThat(((ProcessEngineConfigurationImpl) context.getBean(ProcessEngine.class).getProcessEngineConfiguration()).isAsyncHistoryEnabled()) .isFalse(); })); }
Example #10
Source File: JobTestHelper.java From flowable-engine with Apache License 2.0 | 6 votes |
public static void executeJobExecutorForTime(ProcessEngineConfiguration processEngineConfiguration, long maxMillisToWait, long intervalMillis) { AsyncExecutor asyncExecutor = processEngineConfiguration.getAsyncExecutor(); asyncExecutor.start(); try { Timer timer = new Timer(); InterruptTask task = new InterruptTask(Thread.currentThread()); timer.schedule(task, maxMillisToWait); try { while (!task.isTimeLimitExceeded()) { Thread.sleep(intervalMillis); } } catch (InterruptedException e) { // ignore } finally { timer.cancel(); } } finally { asyncExecutor.shutdown(); } }
Example #11
Source File: JobEntityManager.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void hintAsyncExecutor(Job job) { AsyncExecutor asyncExecutor = Context.getProcessEngineConfiguration().getAsyncExecutor(); CommandContext commandContext = CommandContextUtil.getCommandContext(); TransactionContext transactionContext = org.flowable.common.engine.impl.context.Context.getTransactionContext(); if (transactionContext != null) { JobAddedTransactionListener jobAddedTransactionListener = new JobAddedTransactionListener(job, asyncExecutor, CommandContextUtil.getJobServiceConfiguration(commandContext).getCommandExecutor()); transactionContext.addTransactionListener(TransactionState.COMMITTED, jobAddedTransactionListener); } else { CommandContextCloseListener commandContextCloseListener = new AsyncJobAddedNotification(job, asyncExecutor); Context.getCommandContext().addCloseListener(commandContextCloseListener); } }
Example #12
Source File: AsyncExecutorTwoEnginesTest.java From flowable-engine with Apache License 2.0 | 5 votes |
private int getAsyncExecutorJobCount(ProcessEngine processEngine) { AsyncExecutor asyncExecutor = processEngine.getProcessEngineConfiguration().getAsyncExecutor(); if (asyncExecutor instanceof CountingAsyncExecutor) { return ((CountingAsyncExecutor) asyncExecutor).getCounter().get(); } return 0; }
Example #13
Source File: ProcessAsyncHistoryExecutorTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void asyncHistoryExecutorBeanAvailable() { contextRunner.withPropertyValues("flowable.process.async-history.enable=true").run((context -> { assertThat(context) .hasSingleBean(ProcessEngine.class) .hasBean("taskExecutor") .hasBean("processAsyncExecutor") .hasBean("asyncHistoryExecutor"); AsyncExecutor processAsyncExecutor = context.getBean(ProcessEngine.class).getProcessEngineConfiguration().getAsyncExecutor(); assertThat(processAsyncExecutor).isNotNull(); AsyncExecutor processAsyncHistoryExecutor = context.getBean(ProcessEngine.class).getProcessEngineConfiguration().getAsyncHistoryExecutor(); assertThat(processAsyncHistoryExecutor).isNotNull(); assertThat(processAsyncExecutor).isNotSameAs(processAsyncHistoryExecutor); TaskExecutor taskExecutorBean = context.getBean("taskExecutor", TaskExecutor.class); assertThat(((SpringAsyncExecutor) processAsyncExecutor).getTaskExecutor()).isSameAs(taskExecutorBean); assertThat(((SpringAsyncExecutor) processAsyncHistoryExecutor).getTaskExecutor()).isSameAs(taskExecutorBean); assertThat(context.getBean(ProcessEngine.class).getProcessEngineConfiguration().isAsyncExecutorActivate()).isTrue(); assertThat(context.getBean(ProcessEngine.class).getProcessEngineConfiguration().isAsyncHistoryExecutorActivate()).isTrue(); assertThat(((ProcessEngineConfigurationImpl) context.getBean(ProcessEngine.class).getProcessEngineConfiguration()).isAsyncHistoryEnabled()).isTrue(); })); }
Example #14
Source File: ProcessAsyncHistoryExecutorTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void asyncHistoryExecutorBeanDisabled() { contextRunner .withPropertyValues("flowable.process.async-history.enable=false") .run((context -> { assertThat(context) .hasSingleBean(ProcessEngine.class) .hasBean("taskExecutor") .hasBean("processAsyncExecutor") .doesNotHaveBean("asyncHistoryExecutor"); AsyncExecutor processAsyncExecutor = context.getBean(ProcessEngine.class).getProcessEngineConfiguration().getAsyncExecutor(); assertThat(processAsyncExecutor).isNotNull(); AsyncExecutor processAsyncHistoryExecutor = context.getBean(ProcessEngine.class).getProcessEngineConfiguration().getAsyncHistoryExecutor(); assertThat(processAsyncHistoryExecutor).isNull(); assertThat(processAsyncExecutor).isNotSameAs(processAsyncHistoryExecutor); TaskExecutor taskExecutorBean = context.getBean("taskExecutor", TaskExecutor.class); assertThat(((SpringAsyncExecutor) processAsyncExecutor).getTaskExecutor()).isSameAs(taskExecutorBean); assertThat(context.getBean(ProcessEngine.class).getProcessEngineConfiguration().isAsyncExecutorActivate()).isTrue(); assertThat(context.getBean(ProcessEngine.class).getProcessEngineConfiguration().isAsyncHistoryExecutorActivate()).isTrue(); assertThat(((ProcessEngineConfigurationImpl) context.getBean(ProcessEngine.class).getProcessEngineConfiguration()).isAsyncHistoryEnabled()) .isFalse(); })); }
Example #15
Source File: JobTestHelper.java From flowable-engine with Apache License 2.0 | 5 votes |
public static void waitForJobExecutorToProcessAllJobs(ProcessEngineConfiguration processEngineConfiguration, ManagementService managementService, long maxMillisToWait, long intervalMillis, boolean shutdownExecutorWhenFinished) { AsyncExecutor asyncExecutor = processEngineConfiguration.getAsyncExecutor(); asyncExecutor.start(); try { Timer timer = new Timer(); InterruptTask task = new InterruptTask(Thread.currentThread()); timer.schedule(task, maxMillisToWait); boolean areJobsAvailable = true; try { while (areJobsAvailable && !task.isTimeLimitExceeded()) { Thread.sleep(intervalMillis); try { areJobsAvailable = areJobsAvailable(managementService); } catch (Throwable t) { // Ignore, possible that exception occurs due to locking/updating of table on MSSQL when // isolation level doesn't allow READ of the table } } } catch (InterruptedException e) { // ignore } finally { timer.cancel(); } if (areJobsAvailable) { throw new FlowableException("time limit of " + maxMillisToWait + " was exceeded"); } } finally { if (shutdownExecutorWhenFinished) { asyncExecutor.shutdown(); } } }
Example #16
Source File: ProcessAndCmmnEngineAsyncExecutorTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void cmmnAndProcessEngineShouldUseDistinctAsyncExecutorsWithDefaultConfiguration() { contextRunner.run((context -> { assertThat(context) .hasSingleBean(ProcessEngine.class) .hasSingleBean(CmmnEngine.class) .hasBean("taskExecutor") .hasBean("cmmnAsyncExecutor") .hasBean("processAsyncExecutor"); AsyncExecutor processAsyncExecutor = context.getBean(ProcessEngine.class).getProcessEngineConfiguration().getAsyncExecutor(); AsyncExecutor cmmnAsyncExecutor = context.getBean(CmmnEngine.class).getCmmnEngineConfiguration().getAsyncExecutor(); assertThat(processAsyncExecutor) .as("Process Engine Async Executor vs Cmmn Engine Async Executor") .isNotSameAs(cmmnAsyncExecutor); assertThat(processAsyncExecutor) .as("Process Engine Async Executor") .isInstanceOf(SpringAsyncExecutor.class); assertThat(cmmnAsyncExecutor) .as("Cmmn Engine Async Executor") .isInstanceOf(SpringAsyncExecutor.class); TaskExecutor taskExecutorBean = context.getBean("taskExecutor", TaskExecutor.class); assertThat(((SpringAsyncExecutor) processAsyncExecutor).getTaskExecutor()) .as("Process Async Task Executor") .isSameAs(taskExecutorBean); assertThat(((SpringAsyncExecutor) cmmnAsyncExecutor).getTaskExecutor()) .as("Cmmn Async Task Executor") .isSameAs(taskExecutorBean); })); }
Example #17
Source File: ProcessAndCmmnEngineAsyncExecutorTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void cmmnAndProcessEngineShouldUseDistinctTaskExecutorsWhenPrimaryIsPresent() { contextRunner.withUserConfiguration(DedicatedTaskExecutorsConfiguration.class, PrimaryTaskExecutorConfiguration.class) .run((context -> { AsyncExecutor processAsyncExecutor = context.getBean(ProcessEngine.class).getProcessEngineConfiguration().getAsyncExecutor(); AsyncExecutor cmmnAsyncExecutor = context.getBean(CmmnEngine.class).getCmmnEngineConfiguration().getAsyncExecutor(); assertThat(context) .doesNotHaveBean("taskExecutor") .hasBean("primaryTaskExecutor") .hasBean("cmmnTaskExecutor") .hasBean("processTaskExecutor"); TaskExecutor primaryTaskExecutorBean = context.getBean("primaryTaskExecutor", TaskExecutor.class); TaskExecutor cmmnTaskExecutorBean = context.getBean("cmmnTaskExecutor", TaskExecutor.class); TaskExecutor processTaskExecutorBean = context.getBean("processTaskExecutor", TaskExecutor.class); assertThat(((SpringAsyncExecutor) processAsyncExecutor).getTaskExecutor()) .as("Process Async Task Executor") .isSameAs(processTaskExecutorBean) .isNotSameAs(((SpringAsyncExecutor) cmmnAsyncExecutor).getTaskExecutor()) .as("Process Async Task Executor with primary") .isNotSameAs(primaryTaskExecutorBean); assertThat(((SpringAsyncExecutor) cmmnAsyncExecutor).getTaskExecutor()) .as("Cmmn Async Task Executor") .isSameAs(cmmnTaskExecutorBean) .as("Cmmn Async Task Executor with primary") .isNotSameAs(primaryTaskExecutorBean); })); }
Example #18
Source File: JobTestHelper.java From flowable-engine with Apache License 2.0 | 5 votes |
public static void waitForJobExecutorToProcessAllJobsAndExecutableTimerJobs(ProcessEngineConfiguration processEngineConfiguration, ManagementService managementService, long maxMillisToWait, long intervalMillis, boolean shutdownExecutorWhenFinished) { AsyncExecutor asyncExecutor = processEngineConfiguration.getAsyncExecutor(); asyncExecutor.start(); processEngineConfiguration.setAsyncExecutorActivate(true); try { Timer timer = new Timer(); InterruptTask task = new InterruptTask(Thread.currentThread()); timer.schedule(task, maxMillisToWait); boolean areJobsAvailable = true; try { while (areJobsAvailable && !task.isTimeLimitExceeded()) { Thread.sleep(intervalMillis); try { areJobsAvailable = areJobsOrExecutableTimersAvailable(managementService); } catch (Throwable t) { // Ignore, possible that exception occurs due to locking/updating of table on MSSQL when // isolation level doesn't allow READ of the table } } } catch (InterruptedException e) { // ignore } finally { timer.cancel(); } if (areJobsAvailable) { throw new FlowableException("time limit of " + maxMillisToWait + " was exceeded"); } } finally { if (shutdownExecutorWhenFinished) { processEngineConfiguration.setAsyncExecutorActivate(false); asyncExecutor.shutdown(); } } }
Example #19
Source File: AsyncExecutorTest.java From flowable-engine with Apache License 2.0 | 5 votes |
private int getAsyncExecutorJobCount(ProcessEngine processEngine) { AsyncExecutor asyncExecutor = processEngine.getProcessEngineConfiguration().getAsyncExecutor(); if (asyncExecutor instanceof CountingAsyncExecutor) { return ((CountingAsyncExecutor) asyncExecutor).getCounter().get(); } return 0; }
Example #20
Source File: FlowableEngineConfig.java From plumdo-work with Apache License 2.0 | 5 votes |
@Override public SpringProcessEngineConfiguration springProcessEngineConfiguration(DataSource dataSource, PlatformTransactionManager platformTransactionManager, ObjectProvider<AsyncExecutor> asyncExecutorProvider) throws IOException { SpringProcessEngineConfiguration conf = super.springProcessEngineConfiguration(dataSource, platformTransactionManager, asyncExecutorProvider); String databaseSchema = conf.getDatabaseSchema(); conf.setDatabaseCatalog(databaseSchema); conf.setDatabaseTablePrefix(databaseSchema + "."); conf.setTablePrefixIsSchema(true); conf.setActivityFontName("黑体"); conf.setLabelFontName("黑体"); conf.setAnnotationFontName("黑体"); return conf; }
Example #21
Source File: CmmnJobTestHelper.java From flowable-engine with Apache License 2.0 | 5 votes |
public static void waitForExecutorToProcessAllJobs(final AsyncExecutor asyncExecutor, Callable<Boolean> callable, final long maxMillisToWait, final long intervalMillis, final boolean shutdownExecutorWhenFinished) { if (asyncExecutor == null) { throw new FlowableException("No async executor set. Check the cmmn engine configuration."); } asyncExecutor.start(); try { Timer timer = new Timer(); InterruptTask interruptTask = new InterruptTask(Thread.currentThread()); timer.schedule(interruptTask, maxMillisToWait); boolean areJobsAvailable = true; try { while (areJobsAvailable && !interruptTask.isTimeLimitExceeded()) { Thread.sleep(intervalMillis); try { areJobsAvailable = callable.call(); } catch (Throwable t) { // ignore } } } catch (InterruptedException e) { // ignore } finally { timer.cancel(); } if (areJobsAvailable) { throw new FlowableException("Time limit of " + maxMillisToWait + " was exceeded"); } } finally { if (shutdownExecutorWhenFinished) { asyncExecutor.shutdown(); } } }
Example #22
Source File: SpringCallerRunsRejectedJobsHandler.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void jobRejected(AsyncExecutor asyncExecutor, JobInfo job) { try { // execute rejected work in caller thread (potentially blocking job // acquisition) new ExecuteAsyncRunnable(job, asyncExecutor.getJobServiceConfiguration(), asyncExecutor.getJobServiceConfiguration().getJobEntityManager(), null).run(); } catch (Exception e) { LOGGER.error("Failed to execute rejected job {}", job.getId(), e); } }
Example #23
Source File: CmmnEngineConfigurator.java From flowable-engine with Apache License 2.0 | 5 votes |
protected void copyProcessEngineProperties(ProcessEngineConfigurationImpl processEngineConfiguration) { initProcessInstanceService(processEngineConfiguration); initProcessInstanceStateChangedCallbacks(processEngineConfiguration); initCaseInstanceService(processEngineConfiguration); cmmnEngineConfiguration.setEnableTaskRelationshipCounts(processEngineConfiguration.getPerformanceSettings().isEnableTaskRelationshipCounts()); cmmnEngineConfiguration.setTaskQueryLimit(processEngineConfiguration.getTaskQueryLimit()); cmmnEngineConfiguration.setHistoricTaskQueryLimit(processEngineConfiguration.getHistoricTaskQueryLimit()); // use the same query limit for executions/processes and cases cmmnEngineConfiguration.setCaseQueryLimit(processEngineConfiguration.getExecutionQueryLimit()); cmmnEngineConfiguration.setHistoricCaseQueryLimit(processEngineConfiguration.getHistoricProcessInstancesQueryLimit()); if (processEngineConfiguration.isAsyncHistoryEnabled()) { AsyncExecutor asyncHistoryExecutor = processEngineConfiguration.getAsyncHistoryExecutor(); // Inject the async history executor from the process engine. // The job handlers will be added in the CmmnEngineConfiguration itself cmmnEngineConfiguration.setAsyncHistoryEnabled(true); cmmnEngineConfiguration.setAsyncHistoryExecutor(asyncHistoryExecutor); cmmnEngineConfiguration.setAsyncHistoryJsonGroupingEnabled(processEngineConfiguration.isAsyncHistoryJsonGroupingEnabled()); cmmnEngineConfiguration.setAsyncHistoryJsonGroupingThreshold(processEngineConfiguration.getAsyncHistoryJsonGroupingThreshold()); cmmnEngineConfiguration.setAsyncHistoryJsonGzipCompressionEnabled(processEngineConfiguration.isAsyncHistoryJsonGzipCompressionEnabled()); // See the beforeInit ((CmmnEngineConfiguration) cmmnEngineConfiguration).setHistoryJobExecutionScope(JobServiceConfiguration.JOB_EXECUTION_SCOPE_ALL); } }
Example #24
Source File: TenantAwareResetExpiredJobsRunnable.java From flowable-engine with Apache License 2.0 | 5 votes |
public TenantAwareResetExpiredJobsRunnable(final AsyncExecutor asyncExecutor, TenantInfoHolder tenantInfoHolder, String tenantId) { super("flowable-tenant-" + tenantId + "-" + asyncExecutor.getJobServiceConfiguration().getEngineName() + "-reset-expired-jobs", asyncExecutor, asyncExecutor.getJobServiceConfiguration().getJobEntityManager(), asyncExecutor.getJobServiceConfiguration().getExternalWorkerJobEntityManager() ); this.tenantInfoHolder = tenantInfoHolder; this.tenantId = tenantId; }
Example #25
Source File: ExecutorPerTenantAsyncExecutor.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void setJobServiceConfiguration(JobServiceConfiguration jobServiceConfiguration) { this.jobServiceConfiguration = jobServiceConfiguration; for (AsyncExecutor asyncExecutor : tenantExecutors.values()) { asyncExecutor.setJobServiceConfiguration(jobServiceConfiguration); } }
Example #26
Source File: JobTestHelper.java From flowable-engine with Apache License 2.0 | 5 votes |
protected static void internalWaitForJobs(ProcessEngineConfiguration processEngineConfiguration, ManagementService managementService, Predicate<ManagementService> jobsAvailablePredicate, long maxMillisToWait, long intervalMillis, boolean shutdownExecutorWhenFinished) { AsyncExecutor asyncExecutor = processEngineConfiguration.getAsyncExecutor(); asyncExecutor.start(); processEngineConfiguration.setAsyncExecutorActivate(true); try { Timer timer = new Timer(); InterruptTask task = new InterruptTask(Thread.currentThread()); timer.schedule(task, maxMillisToWait); boolean areJobsAvailable = true; try { while (areJobsAvailable && !task.isTimeLimitExceeded()) { Thread.sleep(intervalMillis); try { areJobsAvailable = jobsAvailablePredicate.test(managementService); } catch (Throwable t) { // Ignore, possible that exception occurs due to locking/updating of table on MSSQL when // isolation level doesn't allow READ of the table } } } catch (InterruptedException e) { // ignore } finally { timer.cancel(); } if (areJobsAvailable) { throw new FlowableException("time limit of " + maxMillisToWait + " was exceeded"); } } finally { if (shutdownExecutorWhenFinished) { processEngineConfiguration.setAsyncExecutorActivate(false); asyncExecutor.shutdown(); } } }
Example #27
Source File: StartTimerEventTest.java From flowable-engine with Apache License 2.0 | 5 votes |
protected int getTimerJobsCount() { int timerJobsCount = processEngineConfiguration.getCommandExecutor().execute(new Command<Integer>() { @Override public Integer execute(CommandContext commandContext) { List<String> enabledCategories = CommandContextUtil.getJobServiceConfiguration().getEnabledJobCategories(); AsyncExecutor asyncExecutor = CommandContextUtil.getProcessEngineConfiguration(commandContext).getAsyncExecutor(); List<TimerJobEntity> timerJobs = CommandContextUtil.getJobServiceConfiguration().getTimerJobEntityManager() .findJobsToExecute(enabledCategories, new Page(0, asyncExecutor.getMaxAsyncJobsDuePerAcquisition())); return timerJobs.size(); } }); return timerJobsCount; }
Example #28
Source File: AsyncExecutorTest.java From flowable-engine with Apache License 2.0 | 5 votes |
private int getAsyncExecutorJobCount(ProcessEngine processEngine) { AsyncExecutor asyncExecutor = processEngine.getProcessEngineConfiguration().getAsyncExecutor(); if (asyncExecutor instanceof CountingAsyncExecutor) { return ((CountingAsyncExecutor) asyncExecutor).getCounter().get(); } return 0; }
Example #29
Source File: JobExecutorCmdHappyTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void testJobCommandsWithTimer() { // clock gets automatically reset in LogTestCase.runTest processEngineConfiguration.getClock().setCurrentTime(new Date(SOME_TIME)); AsyncExecutor asyncExecutor = processEngineConfiguration.getAsyncExecutor(); CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor(); String jobId = commandExecutor.execute(new Command<String>() { @Override public String execute(CommandContext commandContext) { TimerJobEntity timer = createTweetTimer("i'm coding a test", new Date(SOME_TIME + (10 * SECOND))); CommandContextUtil.getTimerJobService(commandContext).scheduleTimerJob(timer); return timer.getId(); } }); AcquiredTimerJobEntities acquiredJobs = commandExecutor.execute(new AcquireTimerJobsCmd(asyncExecutor)); assertThat(acquiredJobs.size()).isZero(); processEngineConfiguration.getClock().setCurrentTime(new Date(SOME_TIME + (20 * SECOND))); acquiredJobs = commandExecutor.execute(new AcquireTimerJobsCmd(asyncExecutor)); assertThat(acquiredJobs.size()).isEqualTo(1); TimerJobEntity job = acquiredJobs.getJobs().iterator().next(); assertThat(job.getId()).isEqualTo(jobId); assertThat(tweetHandler.getMessages()).isEmpty(); Job executableJob = managementService.moveTimerToExecutableJob(jobId); commandExecutor.execute(new ExecuteAsyncJobCmd(executableJob.getId())); assertThat(tweetHandler.getMessages().get(0)).isEqualTo("i'm coding a test"); assertThat(tweetHandler.getMessages()).hasSize(1); }
Example #30
Source File: AcquireTimerJobsCmd.java From flowable-engine with Apache License 2.0 | 4 votes |
public AcquireTimerJobsCmd(AsyncExecutor asyncExecutor) { this.asyncExecutor = asyncExecutor; }