继承和聚合UML(Inheritance and aggregation UML)
想知道UML是否合理且可以接受?
请不要根据类的名称质疑组合或聚合的必要性。
只需按原样处理它们,如UML所示。
另外,我实际上是使用GoodArticle与报纸进行通信而不是实际编码中的父类文章。 但是在表示UML方面,我仍然应该将父类(Article)连接到报纸,即使它实际上是GoodArticle?
这也可以说与GoodArticle与BadArticle的构图连接的情况类似。 BadArticle应该连接到父类文章吗? 然而,我实际上是使用GoodArticle在编码中连接BadArticle。
Would like to know if the UML is reasonable and acceptable?
Please do not question the need for composition or aggregation based on the names of the classes.
Just treat them as they are as shown on the UML.
Also, I am actually using GoodArticle to communicate with Newspaper and not the parent class Article in actual coding. But in terms of representing UML, I should still connect the parent class (Article) to newspaper even though it is actually GoodArticle?
This is also arguably similar to the case where GoodArticle connects with BadArticle for composition. Should BadArticle connect to parent class Article instead? However I am actually using GoodArticle to connect with BadArticle in coding.
原文:
最满意答案
一般来说回答你的问题:Akka创建了一个用于进行异步消息处理的线程池。 因此,如果你编写如下代码,你的应用程序永远不会终止,因为Akka继续运行。
class Root extends Actor { // create some child actors to do some work override def receive: Receive = Actor.emptyBehavior } object Main { def main(args: Array[String]): Unit = { val system = ActorSystem("main") system.actorOf(Props(new Root)) } }
因此,通常如果您需要终止应用程序,您将定义一条消息,表明已完成所有工作并将此消息发送给您的根执行者。 然后,根actor可以调用
context.system.terminate()
来终止系统。回到你的问题,我不明白你为什么要把Akka和Spring Boot结合起来。 你的线程转储,我不确定问题是否与Akka有关。 看起来线程挂在HttpClient中。 您确定已释放并关闭所有打开的连接吗?
To answer your question generally: Akka creates a thread pool which is used to do asynchronous message processing. So if you write code like the following, your application would never terminate since Akka keeps on running.
class Root extends Actor { // create some child actors to do some work override def receive: Receive = Actor.emptyBehavior } object Main { def main(args: Array[String]): Unit = { val system = ActorSystem("main") system.actorOf(Props(new Root)) } }
So usually if you need to terminate your application you would define a message which signals that all work has been done and send this message to your root actor. The root actor can then call
context.system.terminate()
to terminate the system.Coming back to your question, I don't understand why you would want to combine Akka with Spring Boot. Your thread dump, I'm not sure whether the problem is related to Akka at all. It looks like the threads are hanging inside HttpClient. Are you sure you have freed and closed all open connections?
相关问答
更多-
玩家如何使用Akka?(How is Akka used in Play?)[2022-04-19]
在Play 2.0中,Play委托所有请求通过演员。 它严重依赖于Akka未来的API和其他部分。 在Play 2.1中,随着Akka未来的API移动到Scala 2.10,Play开始依赖于Akka。 它从Akka获得所有的执行上下文,并提供与Akka的集成,但这是关于它的程度。 在Play 2.3中,我们正在添加新的功能来帮助Akka集成,特别是在WebSockets周围。 在Play 2.4中,Play将被移植到新的akka-http(以前称为喷雾),在这一点上,Play将像Akka一样建成。 有什么 ... -
使用Akka和Scalatra(Using Akka with Scalatra)[2023-07-26]
您可以在akka引导文件或您自己的ServletContextListener中启动您的actor,以便它们在不与servlet绑定的情况下启动。 然后你可以用akka注册表查找它们。 Actor.registry.actorFor[MyActor] foreach { _ !! (("Run",id), 10000) } 除此之外,目前还没有真正整合akka与scalatra。 因此,到目前为止,您可以做的最好的事情是对一堆演员使用阻止请求。 我不确定,但我不需要为每个请求生成一个actor,而是有一个 ... -
从akka找不到等待(Cannot find Await from akka)[2023-10-28]
正如@SRI 指出你应该使用scala.concurrent.Await而不是akka.dispatch.Await 。 价值? 不是akka.actor.ActorSelection的成员 在版本2.1.4没有对ActorSelection ask模式支持。 看到这个提交 。 支持ActorSelection仅在版本2.2之后可用。 As @S.R.I noted you should use scala.concurrent.Await instead of akka.dispatch.Await. v ... -
使用Akka的logback(Using logback with Akka)[2022-05-31]
我不知道什么是错的,但你可以做到以下几点: 检查你的logback.xml是否在jar文件中 尝试使用java -Dlogback.configurationFile = / path / to / logback.xml -jar event-assembly-0.1.1-SNAPSHOT.jar启动应用程序 So, how I found out, the sbt-assembly removed some logback-binaries from the result jar (it was set ... -
我解决了这两个问题,并将代码迁移到了最新的Akka 2.2-M3版本。 第一个问题的解决方案是让MapReduce远程MasterActor一收到所有消息发出后从客户端发送的TaskInfo通知就立即发回ShutdownInfo通知。 TaskInfo包含MapReduce任务有多少个子任务的信息,例如在这种情况下,文本文件中有多少行。 解决第二个问题的方法是向TaskInfo发送子任务总数。 在这里,AggregatorActor计算它已处理的子任务的数量,并将其与TaskInfo进行比较,并表示作业在匹 ...
-
Scala / Akka语法(Scala/Akka Syntax)[2022-05-11]
在Scala中,任何实现apply方法的对象都可以在没有new关键字的情况下调用,只需调用MyObject() ,它将自动查找它的apply 。 如果您查看Props的伴随对象 ,则会看到以下方法定义: /** * Scala API: Returns a Props that has default values except for "creator" * which will be a function that creates an instance * of the supplied typ ... -
Akka Streams是比演员更高层次的抽象。 它是Reactive Streams的一个实现,它构建在 actor模型之上。 它利用了所有actor的功能,因为它使用了actor。 您甚至可以直接在流的任何部分使用actor。 看看ActorPublisher和ActorSubscriber。 Akka Streams is a higher level abstraction than actors. It's an implementation of Reactive Streams which b ...
-
chunjef的答案是正确的。如果您确实要清除警告,请将以下代码添加到build.sbt中。 conflictManager := ConflictManager.strict dependencyOverrides += "com.typesafe.akka" %% "akka-actor" % "2.5.4" dependencyOverrides += "com.typesafe.akka" %% "akka-stream" % "2.5.4" dependencyOverrides += "o ...
-
一般来说回答你的问题:Akka创建了一个用于进行异步消息处理的线程池。 因此,如果你编写如下代码,你的应用程序永远不会终止,因为Akka继续运行。 class Root extends Actor { // create some child actors to do some work override def receive: Receive = Actor.emptyBehavior } object Main { def main(args: Array[String]): Un ...
-
与akka群集的akka小河(akka-streams with akka-cluster)[2023-07-15]
你可能想让你的Actor扩展ActorPublisher。 然后,您可以从中创建一个源并将其集成到您的流中。 请参阅此处有关ActorPublisher的文档: http ://doc.akka.io/docs/akka-stream-and-http-experimental/2.0.3/scala/stream-integrations.html You probably want to make your Actor extend ActorPublisher. Then you can create ...