Object

net.liftmodules.messagebus

MessageBus

Related Doc: package messagebus

Permalink

object MessageBus extends LiftActor

MessageBus allows to send messages between LiftActors even if they live in separate user sessions. All LiftActors that subscribed to the given Topic will receive messages sent to this Topic.

If you want your actor to subscribe to the given Topic, you need to send the Subscribe message:

case class BeaverPhotosTopic(beaverId: String) extends Topic {
  val name = "beaver-photos-" + beaverId
}

val topic = BeaverPhotosTopic("1")
MessageBus ! Subscribe(this, topic)

from this point, all messages sent to this topic will be received by the actor.

There are two ways to send a message to Topic: For and ForAll. The For class takes a Topic instance and sends a payload only to actors subscribed to this particular Topic. The ForAll class takes a Topic type and sends a payload to all actors subscribed to all Topics of the given type.

Let's consider two listeners:

MessageBus ! Subscribe(listener1, BeaverTopic("1"))
MessageBus ! Subscribe(listener2, BeaverTopic("2"))

If we send a message in the following way:

MessageBus ! For(BeaverTopic("1"), message)

only listener1 will receive it.

However, if we send a message in the following way:

MessageBus ! ForAll[BeaverTopic](message)

Both listener1 and listener2 will receive it.

LiftActor can unsubscribe from the given Topic by sending Unsubscribe message:

MessageBus ! Unsubscribe(this, BeaverTopic("1"))

In case of CometActors, the Subscribe/Unsubscribe actions should usually take place in localSetup and localShutdown methods.

There are no limitations in a number of Topics to which a given LiftActor can be subscribed.

Actors subscribed to Topics should listen for messages in the same way as they listen for any other message types (e.g. implementing messageHandler method or low/medium/highPriority method).

Linear Supertypes
LiftActor, ForwardableActor[Any, Any], GenericActor[Any], TypedActor[Any, Any], SpecializedLiftActor[Any], SimpleActor[Any], AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. MessageBus
  2. LiftActor
  3. ForwardableActor
  4. GenericActor
  5. TypedActor
  6. SpecializedLiftActor
  7. SimpleActor
  8. AnyRef
  9. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Value Members

  1. def !(msg: Any): Unit

    Permalink
    Definition Classes
    SpecializedLiftActor → SimpleActor
  2. def !!(msg: Any): Box[Any]

    Permalink
    Definition Classes
    LiftActor → TypedActor
  3. def !!(msg: Any, timeout: Long): Box[Any]

    Permalink
    Definition Classes
    LiftActor → TypedActor
  4. def !<(msg: Any): LAFuture[Any]

    Permalink
    Definition Classes
    LiftActor
  5. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  6. def !?(timeout: Long, message: Any): Box[Any]

    Permalink
    Definition Classes
    LiftActor → TypedActor
  7. def !?(msg: Any): Any

    Permalink
    Definition Classes
    LiftActor → TypedActor
  8. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  9. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  10. def around[R](f: ⇒ R): R

    Permalink
    Attributes
    protected
    Definition Classes
    SpecializedLiftActor
  11. def aroundLoans: List[CommonLoanWrapper]

    Permalink
    Attributes
    protected
    Definition Classes
    SpecializedLiftActor
  12. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  13. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  14. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  15. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  16. def exceptionHandler: PartialFunction[Throwable, Unit]

    Permalink
    Attributes
    protected
    Definition Classes
    SpecializedLiftActor
  17. def execTranslate(f: (Any) ⇒ Unit)(v: Any): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    LiftActor → SpecializedLiftActor
  18. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  19. final def forwardMessageTo(msg: Any, forwardTo: TypedActor[Any, Any]): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    LiftActor → ForwardableActor
  20. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  21. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  22. def highPriorityReceive: Box[PartialFunction[Any, Unit]]

    Permalink
    Attributes
    protected
    Definition Classes
    SpecializedLiftActor
  23. def insertMsgAtHeadOfQueue_!(msg: Any): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    SpecializedLiftActor
  24. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  25. def messageHandler: PartialFunction[Any, Unit]

    Permalink
    Definition Classes
    MessageBus → SpecializedLiftActor
  26. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  27. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  28. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  29. def reply(v: Any): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    LiftActor → ForwardableActor
  30. def send(msg: Any): Unit

    Permalink
    Definition Classes
    SpecializedLiftActor
  31. def sendAndGetFuture(msg: Any): LAFuture[Any]

    Permalink
    Definition Classes
    LiftActor
  32. def sendAndGetReply(timeout: Long, msg: Any): Any

    Permalink
    Definition Classes
    LiftActor
  33. def sendAndGetReply(msg: Any): Any

    Permalink
    Definition Classes
    LiftActor
  34. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  35. def testTranslate(f: (Any) ⇒ Boolean)(v: Any): Boolean

    Permalink
    Attributes
    protected
    Definition Classes
    LiftActor → SpecializedLiftActor
  36. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  37. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  38. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  39. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from LiftActor

Inherited from ForwardableActor[Any, Any]

Inherited from GenericActor[Any]

Inherited from TypedActor[Any, Any]

Inherited from SpecializedLiftActor[Any]

Inherited from SimpleActor[Any]

Inherited from AnyRef

Inherited from Any

Ungrouped