EngineConfiguration { @Bean public WorkflowInstanceExecutor nflowExecutor(@NFlow ThreadFactory nflowThreadFactory, Environment env) { int threadCount = env.getProperty("nflow.executor.thread.count", Integer.class, 2 * getRuntime().availableProcessors()); int awaitTerminationSeconds = env.getRequiredProperty("nflow.dispatcher.await.termination.seconds", Integer.class); int queueSize = env.getProperty("nflow.dispatcher.executor.queue.size", Integer.class, 2 * threadCount); int notifyThreshold = env.getProperty("nflow.dispatcher.executor.queue.wait_until_threshold", Integer.class, queueSize / 2); int keepAliveSeconds = env.getRequiredProperty("nflow.dispatcher.executor.thread.keepalive.seconds", Integer.class); return new WorkflowInstanceExecutor(queueSize, threadCount, notifyThreshold, awaitTerminationSeconds, keepAliveSeconds, nflowThreadFactory); }  @Bean WorkflowInstanceExecutor nflowExecutor(@NFlow ThreadFactory nflowThreadFactory, Environment env); @Bean @NFlow ThreadFactory nflowThreadFactory(); @Bean @NFlow ObjectMapper nflowObjectMapper(); @Bean @NFlow AbstractResource nflowNonSpringWorkflowsListing(Environment env);  }
@Test public void dispatcherPoolExecutorInstantiationFromThreads() { WorkflowInstanceExecutor executor = configuration.nflowExecutor(threadFactory, environment); assertThat(executor.getQueueRemainingCapacity(), is(200)); }
@Test public void dispatcherPoolExecutorInstantiationFromQueueSize() { environment.setProperty("nflow.dispatcher.executor.queue.size", "10"); WorkflowInstanceExecutor executor = configuration.nflowExecutor(threadFactory, environment); assertThat(executor.getQueueRemainingCapacity(), is(10)); }