akka.stream.actor

ActorPublisher

trait ActorPublisher[T] extends Actor

Extend/mixin this trait in your akka.actor.Actor to make it a stream publisher that keeps track of the subscription life cycle and requested elements.

Create a org.reactivestreams.Publisher backed by this actor with Scala API ActorPublisher#apply, or Java API UntypedActorPublisher#create or Java API compatible with lambda expressions AbstractActorPublisher#create.

It can be attached to a org.reactivestreams.Subscriber or be used as an input source for a akka.stream.scaladsl.Flow. You can only attach one subscriber to this publisher.

The life cycle state of the subscription is tracked with the following boolean members: #isActive, #isCompleted, #isErrorEmitted, and #isCanceled.

You send elements to the stream by calling #onNext. You are allowed to send as many elements as have been requested by the stream subscriber. This amount can be inquired with #totalDemand. It is only allowed to use onNext when isActive and totalDemand > 0, otherwise onNext will throw IllegalStateException.

When the stream subscriber requests more elements the ActorPublisher#Request message is delivered to this actor, and you can act on that event. The #totalDemand is updated automatically.

When the stream subscriber cancels the subscription the ActorPublisher#Cancel message is delivered to this actor. After that subsequent calls to onNext will be ignored.

You can complete the stream by calling #onComplete. After that you are not allowed to call #onNext, #onError and #onComplete.

You can terminate the stream with failure by calling #onError. After that you are not allowed to call #onNext, #onError and #onComplete.

If you suspect that this ActorPublisher may never get subscribed to, you can override the #subscriptionTimeout method to provide a timeout after which this Publisher should be considered canceled. The actor will be notified when the timeout triggers via an akka.stream.actor.ActorPublisherMessage.SubscriptionTimeoutExceeded message and MUST then perform cleanup and stop itself.

If the actor is stopped the stream will be completed, unless it was not already terminated with failure, completed or canceled.

Source
ActorPublisher.scala
Linear Supertypes
Actor, AnyRef, Any
Known Subclasses
Type Hierarchy Learn more about scaladoc diagrams
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. ActorPublisher
  2. Actor
  3. AnyRef
  4. Any
Implicitly
  1. by any2stringadd
  2. by any2stringfmt
  3. by any2ArrowAssoc
  4. by any2Ensuring
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. type Receive = PartialFunction[Any, Unit]

    Definition Classes
    Actor

Abstract Value Members

  1. abstract def receive: actor.Actor.Receive

    Definition Classes
    Actor

Concrete Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. def +(other: String): String

    Implicit information
    This member is added by an implicit conversion from ActorPublisher[T] to StringAdd performed by method any2stringadd in scala.Predef.
    Definition Classes
    StringAdd
  5. def ->[B](y: B): (ActorPublisher[T], B)

    Implicit information
    This member is added by an implicit conversion from ActorPublisher[T] to ArrowAssoc[ActorPublisher[T]] performed by method any2ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  6. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  7. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  8. def aroundPostRestart(reason: Throwable): Unit

    INTERNAL API

    INTERNAL API

    Attributes
    protected[akka]
    Definition Classes
    ActorPublisher → Actor
  9. def aroundPostStop(): Unit

    INTERNAL API

    INTERNAL API

    Attributes
    protected[akka]
    Definition Classes
    ActorPublisher → Actor
  10. def aroundPreRestart(reason: Throwable, message: Option[Any]): Unit

    INTERNAL API

    INTERNAL API

    Attributes
    protected[akka]
    Definition Classes
    ActorPublisher → Actor
  11. def aroundPreStart(): Unit

    INTERNAL API

    INTERNAL API

    Attributes
    protected[akka]
    Definition Classes
    ActorPublisher → Actor
  12. def aroundReceive(receive: Receive, msg: Any): Unit

    INTERNAL API

    INTERNAL API

    Attributes
    protected[akka]
    Definition Classes
    ActorPublisher → Actor
  13. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  14. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  15. implicit val context: ActorContext

    Definition Classes
    Actor
  16. def ensuring(cond: (ActorPublisher[T]) ⇒ Boolean, msg: ⇒ Any): ActorPublisher[T]

    Implicit information
    This member is added by an implicit conversion from ActorPublisher[T] to Ensuring[ActorPublisher[T]] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  17. def ensuring(cond: (ActorPublisher[T]) ⇒ Boolean): ActorPublisher[T]

    Implicit information
    This member is added by an implicit conversion from ActorPublisher[T] to Ensuring[ActorPublisher[T]] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  18. def ensuring(cond: Boolean, msg: ⇒ Any): ActorPublisher[T]

    Implicit information
    This member is added by an implicit conversion from ActorPublisher[T] to Ensuring[ActorPublisher[T]] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  19. def ensuring(cond: Boolean): ActorPublisher[T]

    Implicit information
    This member is added by an implicit conversion from ActorPublisher[T] to Ensuring[ActorPublisher[T]] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  20. final def eq(arg0: AnyRef): Boolean

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

    Definition Classes
    AnyRef → Any
  22. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  23. def formatted(fmtstr: String): String

    Implicit information
    This member is added by an implicit conversion from ActorPublisher[T] to StringFormat performed by method any2stringfmt in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  24. final def getClass(): Class[_]

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

    Definition Classes
    AnyRef → Any
  26. final def isActive: Boolean

    The state when the publisher is active, i.

    The state when the publisher is active, i.e. before the subscriber is attached and when an subscriber is attached. It is allowed to call #onComplete and #onError in this state. It is allowed to call #onNext in this state when #totalDemand is greater than zero.

  27. final def isCanceled: Boolean

    The state after the stream subscriber has canceled the subscription.

    The state after the stream subscriber has canceled the subscription. It is allowed to call #onNext, #onError, and #onComplete in this state, but the calls will not perform anything.

  28. final def isCompleted: Boolean

    The terminal state after calling #onComplete.

    The terminal state after calling #onComplete. It is not allowed to call #onNext, #onError, and #onComplete in this state.

  29. final def isErrorEmitted: Boolean

    The terminal state after calling #onError.

    The terminal state after calling #onError. It is not allowed to call #onNext, #onError, and #onComplete in this state.

  30. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  31. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  32. final def notify(): Unit

    Definition Classes
    AnyRef
  33. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  34. def onComplete(): Unit

    Complete the stream.

    Complete the stream. After that you are not allowed to call #onNext, #onError and #onComplete.

  35. def onCompleteThenStop(): Unit

    Complete the stream.

    Complete the stream. After that you are not allowed to call #onNext, #onError and #onComplete.

    After signalling completion the Actor will then stop itself as it has completed the protocol. When #onComplete is called before any Subscriber has had the chance to subscribe to this ActorPublisher the completion signal (and therefore stopping of the Actor as well) will be delayed until such Subscriber arrives.

  36. def onError(cause: Throwable): Unit

    Terminate the stream with failure.

    Terminate the stream with failure. After that you are not allowed to call #onNext, #onError and #onComplete.

  37. def onErrorThenStop(cause: Throwable): Unit

    Terminate the stream with failure.

    Terminate the stream with failure. After that you are not allowed to call #onNext, #onError and #onComplete.

    After signalling the Error the Actor will then stop itself as it has completed the protocol. When #onError is called before any Subscriber has had the chance to subscribe to this ActorPublisher the error signal (and therefore stopping of the Actor as well) will be delayed until such Subscriber arrives.

  38. def onNext(element: T): Unit

    Send an element to the stream subscriber.

    Send an element to the stream subscriber. You are allowed to send as many elements as have been requested by the stream subscriber. This amount can be inquired with #totalDemand. It is only allowed to use onNext when isActive and totalDemand > 0, otherwise onNext will throw IllegalStateException.

  39. def postRestart(reason: Throwable): Unit

    Definition Classes
    Actor
    Annotations
    @throws( classOf[java.lang.Exception] )
  40. def postStop(): Unit

    Definition Classes
    Actor
    Annotations
    @throws( classOf[java.lang.Exception] )
  41. def preRestart(reason: Throwable, message: Option[Any]): Unit

    Definition Classes
    Actor
    Annotations
    @throws( classOf[java.lang.Exception] )
  42. def preStart(): Unit

    Definition Classes
    Actor
    Annotations
    @throws( classOf[java.lang.Exception] )
  43. implicit final val self: ActorRef

    Definition Classes
    Actor
  44. final def sender(): ActorRef

    Definition Classes
    Actor
  45. def subscriptionTimeout: Duration

    Subscription timeout after which this actor will become Canceled and reject any incoming "late" subscriber.

    Subscription timeout after which this actor will become Canceled and reject any incoming "late" subscriber.

    The actor will receive an SubscriptionTimeoutExceeded message upon which it MUST react by performing all necessary cleanup and stopping itself.

    Use this feature in order to avoid leaking actors when you suspect that this Publisher may never get subscribed to by some Subscriber.

  46. def supervisorStrategy: SupervisorStrategy

    Definition Classes
    Actor
  47. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  48. def toString(): String

    Definition Classes
    AnyRef → Any
  49. final def totalDemand: Long

    Total number of requested elements from the stream subscriber.

    Total number of requested elements from the stream subscriber. This actor automatically keeps tracks of this amount based on incoming request messages and outgoing onNext.

  50. def unhandled(message: Any): Unit

    Definition Classes
    Actor
  51. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  54. def [B](y: B): (ActorPublisher[T], B)

    Implicit information
    This member is added by an implicit conversion from ActorPublisher[T] to ArrowAssoc[ActorPublisher[T]] performed by method any2ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Shadowed Implicit Value Members

  1. val self: Any

    Implicit information
    This member is added by an implicit conversion from ActorPublisher[T] to StringAdd performed by method any2stringadd in scala.Predef.
    Shadowing
    This implicitly inherited member is shadowed by one or more members in this class.
    To access this member you can use a type ascription:
    (actorPublisher: StringAdd).self
    Definition Classes
    StringAdd
  2. val self: Any

    Implicit information
    This member is added by an implicit conversion from ActorPublisher[T] to StringFormat performed by method any2stringfmt in scala.Predef.
    Shadowing
    This implicitly inherited member is shadowed by one or more members in this class.
    To access this member you can use a type ascription:
    (actorPublisher: StringFormat).self
    Definition Classes
    StringFormat

Deprecated Value Members

  1. def x: ActorPublisher[T]

    Implicit information
    This member is added by an implicit conversion from ActorPublisher[T] to ArrowAssoc[ActorPublisher[T]] performed by method any2ArrowAssoc in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (actorPublisher: ArrowAssoc[ActorPublisher[T]]).x
    Definition Classes
    ArrowAssoc
    Annotations
    @deprecated
    Deprecated

    (Since version 2.10.0) Use leftOfArrow instead

  2. def x: ActorPublisher[T]

    Implicit information
    This member is added by an implicit conversion from ActorPublisher[T] to Ensuring[ActorPublisher[T]] performed by method any2Ensuring in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (actorPublisher: Ensuring[ActorPublisher[T]]).x
    Definition Classes
    Ensuring
    Annotations
    @deprecated
    Deprecated

    (Since version 2.10.0) Use resultOfEnsuring instead

Inherited from Actor

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from ActorPublisher[T] to StringAdd

Inherited by implicit conversion any2stringfmt from ActorPublisher[T] to StringFormat

Inherited by implicit conversion any2ArrowAssoc from ActorPublisher[T] to ArrowAssoc[ActorPublisher[T]]

Inherited by implicit conversion any2Ensuring from ActorPublisher[T] to Ensuring[ActorPublisher[T]]

Ungrouped