Akka Spring Integration

Akka的官方文档上只有1.3.1版本有Spring Integration的部分,为啥到了2.2版本却不支持Spring集成了呢?R2有一段可参考:

The akka-spring module was not ported to the Akka 2.x series because it conflicts with the way actor systems work: with parental supervision only actors create other actors, which means that Spring—not being an actor—cannot create actors.
There is a new section in the documentation for the upcoming 2.2 release about how to use dependency injection while creating actors (see the docs). We are working on a more complete document describing the interplay between DI frameworks and Akka.

主要是说Akka 2.x必须通过actor来创建actor,否则Akka的supervision机制就不能发挥作用了。Nevertheless, Akka 2.x还是提供了和Dependency Injection配合的方式,见R3。准备测试一下这种官方的集成方式。

网上还看到一种集成方式,见R1,是写于May 2013的博客,但不知是针对什么Akka版本,但由于其内容的简单性,准备也测试一下。

<!-- AKKA System Setup -->
<bean id="myActorSystem" class="akka.actor.ActorSystem" factory-method="create" destroy-method="shutdown" scope="singleton">
    <constructor-arg value="mySpingAkkaSystem"/>
</bean>
R1提供的这段配置可让Spring Container创建一个ActorSystem的实例,我们可以把这个bean注入到我们自己的bean里面,然后就可创建actor了。

等有空了对上面两种方式进行测试并报告结果。


UPDATE: R4 is the official means.


Reference 1: Integrating Akka with Spring & Java Web Applications. http://blog.nemccarthy.me/?p=295

Reference 2: http://stackoverflow.com/questions/16948292/why-spring-integration-doc-for-akka-exists-only-for-1-3-1-but-not-for-next-versi

Reference 3: http://doc.akka.io/docs/akka/2.2.0-RC1/java/untyped-actors.html#Creating_Actors_with_Factory_Methods

Reference 4: https://github.com/typesafehub/activator-akka-java-spring


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值