I am studying the Akka EventBus to check if it can solve one of my design problem and I still do not know. The problem is the following.
to simplify, I have:
case class Request(requesterId: String, operation: String, header: RequestHeader)
case class Response(requesterId: String, operation: String, header: ResponseHeader)
I have several actors with different functions, and I want some actor to subscribe to Response
depending on the requesterId
, some others depending on the operation
.
Is there a way to achieve that easily, with EventBus and classifiers?
Thanks, Joel
Sure, it's called LookupEventBus. You implement your own bus by extending it and extract the
requesterId
in theclassify
method, like this:Then you'd subscribe to a given
requesterId
, like so:And this Actor will then receive only messages hich have been classified as
requester-100
.