将 Akka 与 Spring 和 OSGI 集成(找不到键"akka"的配置设置)



我已经添加了一个Akka演员到我的应用程序与SpringOSGI工作。

我尝试使用Actor从Spring @Component bean这样:

private final ActorSystem system = ActorSystem.create("actor-system");
private ActorRef managerActorRef = system.actorOf(Props.create(ManagerActor.class), "ldapManagerActor");

当我启动应用程序时,它抛出一个异常(No configuration setting found for key 'akka'):

Instantiation of bean failed; nested exception is org.springframework.
beans.BeanInstantiationException: Could not instantiate bean class [com.myconpany....ByBean]: Constructor threw exception; nested exception is com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'akka'

我看过这个:doc。似乎我的问题的根源与class loader有关,我应该传递到/akka-systemapplication.conf文件来描述这一点。

但是到目前为止我还没有找到合适的stets来使它全部工作。

有人能帮忙吗?


My tries:

阅读这篇文章。

当我输入:

<bean id="actorSystem" class="akka.actor.ActorSystem" factory-method="create" scope="singleton"></bean>

我有类似的错误:

Could not autowire field: private akka.actor.ActorSystem
com.typesafe.config.ConfigException$Missing: No configuration setting fou
nd for key 'akka'

如果你只想使用Akka actor,你不需要传入application.conf设置。您可以使用默认值。确保在类路径上有配置库。

你没有提到你使用什么版本的Akka,但是如果你抓住最新的Akka 2.2 RC,你可以使用IndirectActorProducer来处理弹簧接线。

查看这篇文章如何做到这一点;http://blog.nemccarthy.me/?p=272

你还应该告诉Spring在ActorSystem上调用shutdown来干净地关闭。这里还有一个关于如何将ActorSystem集成到Spring或web应用程序中的最新指南

最新更新