Grakka is a simple demonstration application showing how to integrate Grails 3.x and Akka 2.4.
Grakka integrates Grails and Akka following the same Spring context integration approach demonstrated in Typesafe's activator-akka-java-spring demo.
The QualiMente blog post Integrating Grails and Akka, provides an in-depth explanation of the integration.
The key of the design is that the Spring context is responsible for creating both Grails objects and Akka actors. Since Spring is responsible for object creation a number of nice features are available automatically:
- Grails objects may be injected with Akka objects, e.g. NumberController is injected with the ActorSystem
- Akka actors may be injected with Grails objects, e.g. NumberActor is injected with a Grails Service
The availability of bi-directional injection of resources enables the application designer to decide which way(s) dependencies should flow through the application.
There are few classes that collaborate to implement the integration, all in grails-app/utils/conf:
- AkkaSpringConfiguration - a Spring context definition that defines the Akka actor system as a Spring bean, supplementing the standard Spring context defined by Grails by importing the context in resources.groovy
- SpringExtension - an extension to the Akka actor system that enables actor creation to be performed by the SpringActorProducer
- SpringActorProducer - an implementation of Akka's IndirectActorProducer that delegates actor creation to Spring
Thank you very much to the folks who make tech like grakka possible:
- Grails
- Akka sponsored by Typesafe
- Spring Framework sponsored by Pivotal