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

4

我将一个 Akka actor 添加到了我的应用中,该应用与 SpringOSGI 兼容。

我试图像下面这样从 Spring @Component bean 中使用 Actor:

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

当我启动应用程序时,它会抛出一个异常(找不到键“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。似乎我的问题根源与应该传递给/为 akka-system 和描述其内容的 application.conf 文件的 class loader 有关。

但到目前为止,我还没有找到合适的 stets 使其正常工作。

能有人帮忙吗?


我的尝试:

参考这篇文章。

当我输入:

<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'

1
你有一个application.conf文件吗?如果有的话,能否将其发布,并让我知道该文件是否位于类路径的根目录下。 - cmbaxter
已经有了。我刚刚把所有 akka-actor_.jar/reference.conf 中的内容放在那里。看起来它开始工作了。很快会检查一下。 - ses
1个回答

1
如果您只想使用Akka actors,则无需传递application.conf设置。您可以使用默认值。确保在类路径上有config库。
您没有提到您正在使用哪个Akka版本,但是如果您获取最新的Akka 2.2 RC,则可以使用IndirectActorProducer来处理spring连接。
请参阅此文章以了解如何执行此操作; http://blog.nemccarthy.me/?p=272 您还应该告诉Spring调用ActorSystem以进行清除关闭。还有一个更新的指南,介绍了如何将ActorSystem集成到Spring或Web应用程序here

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接