Package akka.stream.typed.scaladsl
Class PubSub$
- java.lang.Object
-
- akka.stream.typed.scaladsl.PubSub$
-
public class PubSub$ extends java.lang.Object
Sources and sinks to integrateTopic
with streams allowing for local or distributed publishing and subscribing of elements through a stream.
-
-
Constructor Summary
Constructors Constructor Description PubSub$()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Sink<T,NotUsed>
sink(ActorRef<Topic.Command<T>> topicActor)
Create a sink that will publish each message to the given topic.<T> Source<T,NotUsed>
source(ActorRef<Topic.Command<T>> topicActor, int bufferSize, OverflowStrategy overflowStrategy)
Create a source that will subscribe to a topic and stream messages published to the topic.
-
-
-
Field Detail
-
MODULE$
public static final PubSub$ MODULE$
Static reference to the singleton instance of this Scala object.
-
-
Method Detail
-
source
public <T> Source<T,NotUsed> source(ActorRef<Topic.Command<T>> topicActor, int bufferSize, OverflowStrategy overflowStrategy)
Create a source that will subscribe to a topic and stream messages published to the topic. Can be materialized multiple times, each materialized stream will contain messages published after it was started.Note that it is not possible to propagate the backpressure from the running stream to the pub sub topic, if the stream is backpressuring published messages are buffered up to a limit and if the limit is hit the configurable
OverflowStrategy
decides what happens. It is not possible to use theBackpressure
strategy.- Parameters:
topicActor
- The actor ref for anakka.actor.typed.pubsub.Topic
actor representing a specific topic.bufferSize
- The maximum number of messages to buffer if the stream applies backpressureoverflowStrategy
- Strategy to use once the buffer is full.
-
sink
public <T> Sink<T,NotUsed> sink(ActorRef<Topic.Command<T>> topicActor)
Create a sink that will publish each message to the given topic. Note that there is no backpressure from the topic, so care must be taken to not publish messages at a higher rate than that can be handled by subscribers. If the topic does not have any subscribers when a message is published or the topic actor is stopped, the message is sent to dead letters.- Parameters:
topicActor
- The actor ref for anakka.actor.typed.pubsub.Topic
actor representing a specific topic.
-
-