我有一个Akka ActorEventBus
(引用https://github.com/akka/akka/blob/master/akka-actor/src/main/scala/akka/event/EventBus.scala#L70),可以处理大量传递给不同演员的消息。
我已经设置了一个Actor来订阅这个总线:
/**
* special actor that transports messages to the hive
*/
val hiveTalk = {
val subscriber = actorSystem.actorOf(Props(new HiveTransport))
Bus.subscribe( subscriber, "/app/browser/" )
Bus.subscribe( subscriber, "/app/mobile/" )
}
作为MessageBus
的实现的ActorEventBus
类如下所示:
/**
* message bus to route messages to their appropriate contexts
*/
class MessageBus extends ActorEventBus with LookupClassification {
type Event = MessageEvent
type Classifier = String
protected def mapSize(): Int = {
10
}
protected def classify(event: Event): Classifier = {
event.channel
}
protected def publish(event: Event, subscriber: Subscriber): Unit = {
subscriber ! event
}
}
出于某种原因,/app/browser/26
演员订阅者未收到发送到hiveTalk
子频道的消息。
任何想法为什么?
答案 0 :(得分:2)
解决。显然Lookup Classification
实际上只是一个简单的单通道实现。
Subchannel Classification
是实际实现子频道的Akka特征。
http://doc.akka.io/docs/akka/2.0/scala/event-bus.html#Subchannel_Classification