I want to implement some kind of message bus in one of my Scala applications. Functions:
- subscription to 1 .. N message types
- messages can have a payload
- free communication (nodes contain only a link to the bus)
- Lightweight (no full-scale enterprise message queue, etc.)
What I plan to do is implement all the nodes and the bus itself as standard Scala actors. For example, I want to define a characteristic Subscriberas follows:
trait Subscriber[M <: Message[_]] {
this: Actor =>
def notify(message: M)
}
Ideally, mixing in this attribute should already register a subscription for the type M.
How does this idea make sense? Are there better ways to implement a message bus?