简体   繁体   English

创建Akka消息侦听器而不扩展Actor类

[英]Create akka message listener without extending Actor class

As I have seen from samples that one should be an actor in order to catch a message. 正如我从样本中看到的那样,为了捕捉信息,一个人应该是一个演员。 But I need a custom listener in order to listen messages without creating a new actor class etc. I want something like this: 但是我需要一个自定义的侦听器,以便在不创建新的actor类等的情况下侦听消息。我想要这样的东西:

throw message

listen Response{
   ...
}

Any usage like that? 这样的用法吗?

Thx 谢谢

EDIT: My purpose is to write a CEP and this CEP will need some business scenarios in order to produce outputs. 编辑:我的目的是编写一个CEP,此CEP需要一些业务场景才能产生输出。 So a scenario like this will occur: 因此,将发生以下情况:

Check if customer.internetusage>1000 check if quota exceeded fraud check ... 检查customer.internetusage> 1000是否检查配额是否超过欺诈检查...

This needs to be injected at runtime so I need a kind of structure in order to write a scenario like above. 这需要在运行时注入,因此我需要一种结构来编写上述场景。

You can subscribe to the event-bus. 您可以订阅事件总线。 You just need to implement the traits defined here: http://doc.akka.io/docs/akka/current/scala/event-bus.html 您只需要实现此处定义的特征: http : //doc.akka.io/docs/akka/current/scala/event-bus.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM