@Test
 public void verifyDifferentThread() throws Exception {
   SimpleAsyncTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor();
   taskExecutor.setThreadNamePrefix("test-");
   ExecutorChannel channel = new ExecutorChannel(taskExecutor);
   CountDownLatch latch = new CountDownLatch(1);
   TestHandler handler = new TestHandler(latch);
   channel.subscribe(handler);
   channel.send(new GenericMessage<String>("test"));
   latch.await(1000, TimeUnit.MILLISECONDS);
   assertEquals(0, latch.getCount());
   assertNotNull(handler.thread);
   assertFalse(Thread.currentThread().equals(handler.thread));
   assertEquals("test-1", handler.thread.getName());
 }
  private TaskExecutor createDefaultTaskExecutor() {
    // create thread-pool for starting contexts
    ThreadGroup threadGroup =
        new ThreadGroup(
            "eclipse-gemini-blueprint-extender["
                + ObjectUtils.getIdentityHexString(this)
                + "]-threads");
    threadGroup.setDaemon(false);

    SimpleAsyncTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor();
    taskExecutor.setThreadGroup(threadGroup);
    taskExecutor.setThreadNamePrefix("EclipseGeminiBlueprintExtenderThread-");

    isTaskExecutorManagedInternally = true;

    return taskExecutor;
  }
Ejemplo n.º 3
0
 @Bean
 public SimpleAsyncTaskExecutor taskExecutor() {
   SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor();
   executor.setConcurrencyLimit(1);
   return executor;
 }