Skip to content

Instantly share code, notes, and snippets.

@zeroows
Created February 17, 2015 07:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeroows/7da2264f98812c5b6bcd to your computer and use it in GitHub Desktop.
Save zeroows/7da2264f98812c5b6bcd to your computer and use it in GitHub Desktop.
Setting up Akka in spring JavaConfig
/**
* To support Akka
*
* @return
*/
@Configuration
protected static class AkkaConfiguration {
// The application context is needed to initialize the Akka Spring
// Extension
@Autowired
private ApplicationContext applicationContext;
@Autowired
private SpringExtension springExtension;
/**
* Actor system singleton for this application.
*/
@Bean
public ActorSystem actorSystem() {
ActorSystem system = ActorSystem.create("AkkaTaskProcessing", akkaConfiguration());
// Initialize the application context in the Akka Spring Extension
springExtension.initialize(applicationContext);
return system;
}
/**
* Read configuration from application.conf file
*/
@Bean
public Config akkaConfiguration() {
return ConfigFactory.load("akka");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment