Hazelcast。注册IExecutorService

时间:2017-10-12 13:09:38

标签: spring-boot hazelcast executorservice executor

我正在阅读Hazelcast文档(http://docs.hazelcast.org/docs/latest-development/manual/html/Distributed_Computing/Executor_Service/Implementing_a_Runnable_Task.html

要在云环境中管理Executor,hazelcast检索Executor就像......

public class MasterMember {
  public static void main( String[] args ) throws Exception {
    HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance();
    IExecutorService executor = hazelcastInstance.getExecutorService( "exec" );
    for ( int k = 1; k <= 1000; k++ ) {
      Thread.sleep( 1000 );
      System.out.println( "Producing echo task: " + k );
      executor.execute( new EchoTask( String.valueOf( k ) ) );
    }
    System.out.println( "EchoTaskMain finished!" );
  }
}

但是,我找不到名为exec的ExecutorService注册部分。我想知道如何将Executor注册到HazelcastInstance

仅供参考,我的项目基于Spring启动,并启动HazelcastInstance,如下所示(ApplicationContextAware实施中)

public static HazelcastInstance getHazelcastIntance(){
    return context.getBean(HazelcastInstance.class) ;
}

摘要。我想知道如何将Executor注册到HazelcastInstance。 感谢。

===============================================

编辑。

我的应用程序Context中有一个TaskExecutor bean。 但我无法使用Spring IExecutorService bean生成TaskExecutor

IExecutorService executor = hazelcastInstance.getExecutorService("taskExecutor");
executor.execute(new ParallelDBSyncExecutor(executeId) {
          @Override
          public void action() throws Exception {
                            this.dbSyncService.executeWithIteration(this.executeId, start, total);
          }
});

Hazelcast可以检测已经注册的Spring bean吗?

0 个答案:

没有答案