如何在单例ActorSystem中管理Actor关闭 [英] How to manage actor shutdown in a singleton ActorSystem

查看:391
本文介绍了如何在单例ActorSystem中管理Actor关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有一个singleton actor系统,除了在同一个JVM中加载和卸载相同的应用程序进行测试时,我会遇到一个错误,因为我在启动过程中尝试重新创建,因此它工作正常。

I have a singleton actor system in my application, and this works perfectly fine except that when the same application is loaded and unloaded inside the same JVM for testing, I have an error because I try, in my startup procedure, to recreate an actor which already exists.

结果是我得到了 akka.actor.InvalidActorNameException ,因为Actor名称是不是唯一的。

As a result I get an akka.actor.InvalidActorNameException because the Actor name is not unique.

我正在寻找一种方法,可以根据角色系统平稳地关闭角色,而不关闭角色系统本身。

I am looking for a way to smoothly shutdown the actors depending on the actor systems without shutting down the actor system itself. Which is a reasonable strategy for that?

推荐答案

这不是您问题的确切答案- ... a平滑关闭参与者的方法... ,但是您提到能够在同一JVM中启动两个应用程序。

This is not exactly answer to your question - "... a way to smoothly shutdown the actors ...", but you mentioned that you are able to able to start two applicatons in same JVM.

您的actor系统是应用程序实例中的单个,而不是整个JVM中的singleton?

Could you make your actor system to be singleton within application instance instead of singleton within whole JVM?

您将有两个独立的actor系统,您不会具有名称冲突,无需启动/停止特定演员。

You would have two independent actor systems, you won't have name conflicts and won't have to start/stop specific actors.

我想问题可能在于某些参与者是否正在与外界进行交互,例如,使用来自JMS的消息等。那么,不清楚哪个参与者系统正在处理他们。

I guess problems could be if some of actors are interacting with outside world, for example consuming some messages from JMS etc. Then it would not be obvious which actor system is processing them.

这篇关于如何在单例ActorSystem中管理Actor关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆