Class ActorFlow


  • public class ActorFlow
    extends Object
    Provides a flow that is handled by an actor.

    See https://github.com/akka/akka/issues/16985.

    • Constructor Detail

      • ActorFlow

        public ActorFlow()
    • Method Detail

      • actorRef

        public static <In,​Out> Flow<In,​Out,​?> actorRef​(Function<ActorRef,​Props> props,
                                                                         int bufferSize,
                                                                         OverflowStrategy overflowStrategy,
                                                                         ActorRefFactory factory,
                                                                         Materializer mat)
        Create a flow that is handled by an actor.

        Messages can be sent downstream by sending them to the actor passed into the props function. This actor meets the contract of the actor returned by Source.actorRef(int, org.apache.pekko.stream.OverflowStrategy).

        The props function should return the props for an actor to handle the flow. This actor will be created using the passed in ActorRefFactory. Each message received will be sent to the actor - there is no back pressure, if the actor is unable to process the messages, they will queue up in the actors mailbox. The upstream can be cancelled by the actor terminating itself.

        Type Parameters:
        In - the In type parameter for a Flow
        Out - the Out type parameter for a Flow
        Parameters:
        props - A function that creates the props for actor to handle the flow.
        bufferSize - The maximum number of elements to buffer.
        overflowStrategy - The strategy for how to handle a buffer overflow.
        factory - The Actor Factory used to create the actor to handle the flow - for example, an ActorSystem.
        mat - The materializer to materialize the flow.
        Returns:
        the flow itself.
      • actorRef

        public static <In,​Out> Flow<In,​Out,​?> actorRef​(Function<ActorRef,​Props> props,
                                                                         ActorRefFactory factory,
                                                                         Materializer mat)
        Create a flow that is handled by an actor.

        Messages can be sent downstream by sending them to the actor passed into the props function. This actor meets the contract of the actor returned by Source.actorRef(int, org.apache.pekko.stream.OverflowStrategy), defaulting to a buffer size of 16, and failing the stream if the buffer gets full.

        The props function should return the props for an actor to handle the flow. This actor will be created using the passed in ActorRefFactory. Each message received will be sent to the actor - there is no back pressure, if the actor is unable to process the messages, they will queue up in the actors mailbox. The upstream can be cancelled by the actor terminating itself.

        Type Parameters:
        In - the In type parameter for a Flow
        Out - the Out type parameter for a Flow
        Parameters:
        props - A function that creates the props for actor to handle the flow.
        factory - The Actor Factory used to create the actor to handle the flow - for example, an ActorSystem.
        mat - The materializer to materialize the flow.
        Returns:
        the flow itself.