/** Actor system singleton for this application. */ @Bean public ActorSystem actorSystem() { // load the Akka configuration String seedNodes = "["; for (String seed : clusterConfig.getSeedNodes()) { seedNodes += "\"akka.tcp://" + clusterConfig.getName() + "@" + seed.trim() + "\","; } seedNodes += "]"; final Config applicationConf = ConfigFactory.load(); final Config config = ConfigFactory.parseString("akka.cluster.seed-nodes=" + seedNodes) .withFallback( ConfigFactory.parseString( "akka.remote.netty.tcp.bind-port=" + clusterConfig.getLocalPort())) .withFallback( ConfigFactory.parseString( "akka.remote.netty.tcp.hostname=" + clusterConfig.getNodeHost())) .withFallback( ConfigFactory.parseString( "akka.remote.netty.tcp.port=" + clusterConfig.getLocalPort())) .withFallback(ConfigFactory.parseString("akka.cluster.roles=[matcher]")) .withFallback(ConfigFactory.load(applicationConf)); ActorSystem system = ActorSystem.create(clusterConfig.getName(), config); LoggingAdapter log = Logging.getLogger(system, this); log.info("Using Akka system settings: " + system.settings().toString()); // initialize the application context in the Akka Spring Extension SpringExtension.SpringExtProvider.get(system).initialize(applicationContext); return system; }
public static void main(String[] args) throws IOException { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(MatcherServiceAppConfiguration.class); ActorSystem system = ctx.getBean(ActorSystem.class); ActorRef wonNodeControllerActor = system.actorOf( SpringExtension.SpringExtProvider.get(system).props(WonNodeControllerActor.class), "WonNodeControllerActor"); }