Showing posts with label akka. Show all posts
Showing posts with label akka. Show all posts
Sunday, May 5, 2013
akka and cdi are good friends
today i implemented a small lib (less than 100 lines of code) which integrates akka and cdi.
it supports injection of akka artifacts (ActorRef and ActorSystem) in cdi-beans as well injection of cdi-beans in actors.
examples:
this lib doesn't intend to provide a full integration. it should just illustrate how easy it is to use akka in combination with cdi (and to integrate both).
(parts of it are done with deltaspike, however, it's easy to replace (copy) the needed parts to avoid a dependency.)
you just need to be aware of some basic rules given by actor-frameworks (some details are mentioned here).
Saturday, February 23, 2013
[add-on] owb and actors
actor-frameworks for the jvm gain more popularity every day. even with actor-frameworks you have to be careful with shared state. however, if you have a java-ee application, you can (re-)use stateless services in your actors easily. one use-case is to resolve transactional beans (ejbs, cdi-beans which are annotated e.g. with @Transactional, ...) in an actor and invoke methods on them to access a database.
with an ee-application-server like tomee that works out-of-the-box. you just have to bootstrap an actor-framework (like akka, jetlang,...) and use the std. java-ee api to lookup the bean/s.
if you are interested in using transactional cdi beans, you can use the jpa-module provided by apache deltaspike v0.4+ (note: those transactions don't span across actors). for using @Transactional, you just have to follow the documentation and you are done. that's usually a short story. but...
if you would like to use @Singleton or @ApplicationScoped beans and you are using the openwebbeans-web module of owb v1.1.x, you need an additional plugin (due to OWB-785). in such cases just get https://github.com/os890/owb-contexts_service-addon.git, build it and add it as runtime dependency to your project.
-> you are done (there is no additional api you have to use).
additional hint:
apache deltaspike provides some nice helpers (like BeanProvider#getContextualReference to resolve cdi-beans), interceptors (like @Transactional), scopes (like @TransactionScoped) and much more...
Labels:
actors,
akka,
cdi,
deltaspike,
github,
java-ee,
jetty,
jsr 299,
openwebbeans,
owb,
owb-add-on,
scopes,
tomcat,
tomee,
transactions
Subscribe to:
Posts (Atom)