As my Play 1.2.x project grows, I’m finding myself adding stuff here
and there when doing certain things (persisting objects, etc.) and my code gets quite mixed up.
I think the best way to handle these kind of use cases would be using an Eventbus.. but which one?
There’s
- http://code.google.com/p/simpleeventbus/
- The one from Google Guava http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/eventbus/package-summary.html
and probably some more….
I’ve seen that Play 2.x is able to use the akka 2.0 event bus… but as the scala plugin is still using an old sbt/scala version, I’m unable to use the Akka 2 with play 1.2.x
I’d be glad to read what message buses you’re using in your Play Projects.
Please also explain how your solution handles persistence operations, e.g. how to be able to use the JPA Session from a listener.
Thanks,
Dominik
Are you still looking at integrating AKKA with Play 1.2? I have just completed integration with Play 1.2.5. I looked at the module for AKKA, but it was fairly out of date, so I decided to integrate AKKA myself.
It is all quite simple here are some basic steps:
In your dependencies.yml file include the line
com.typesafe.akka -> akka-actor_2.10 2.1.0 // this was the latest version at time of writingexecute from the command line play deps to download the relevant libraries into your lib folder
setup in your conf directory a reference.conf file (this will contain config info for akka on start) – look at: http://doc.akka.io/docs/akka/2.1.0/general/configuration.html
"-Dconfig.file=reference.conf"to your VM optionsLoad the AKKA system with:
That should be enough to get running, then you just have to create some Actors to do your bidding.
I also got JPA working – if you try and access your models and lookup data, you will end up with an Uninitialised Entity Manager error.
Here is some example code for an actor with JPA access:
Hope this helps. I spent a good few hours trying to get everything working. I am now able to structure my async tasks rather than just spit out to Play Jobs.