Class Sink<In,Mat>
- java.lang.Object
- 
- org.apache.pekko.stream.javadsl.Sink<In,Mat>
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.apache.pekko.stream.GraphGraph.GraphMapMatVal<S extends Shape,M>
 
- 
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <In> Sink<In,NotUsed>actorRef(ActorRef ref, java.lang.Object onCompleteMessage)Sends the elements of the stream to the givenActorRef.static <In> Sink<In,NotUsed>actorRefWithAck(ActorRef ref, java.lang.Object onInitMessage, java.lang.Object ackMessage, java.lang.Object onCompleteMessage, Function<java.lang.Throwable,java.lang.Object> onFailureMessage)Deprecated.Use actorRefWithBackpressure insteadstatic <In> Sink<In,NotUsed>actorRefWithBackpressure(ActorRef ref, java.lang.Object onInitMessage, java.lang.Object ackMessage, java.lang.Object onCompleteMessage, Function<java.lang.Throwable,java.lang.Object> onFailureMessage)Sends the elements of the stream to the givenActorRefthat sends back back-pressure signal.static <In> Sink<In,NotUsed>actorRefWithBackpressure(ActorRef ref, java.lang.Object onInitMessage, java.lang.Object onCompleteMessage, Function<java.lang.Throwable,java.lang.Object> onFailureMessage)Sends the elements of the stream to the givenActorRefthat sends back back-pressure signal.Sink<In,Mat>addAttributes(Attributes attr)Add the given attributes to thisSink.static <T> Sink<T,org.reactivestreams.Publisher<T>>asPublisher(AsPublisher fanout)ASinkthat materializes into aPublisher.Sink<In,Mat>asScala()Converts this Sink to its Scala DSL counterpart.Sink<In,Mat>async()Put an asynchronous boundary around thisSinkSink<In,Mat>async(java.lang.String dispatcher)Put an asynchronous boundary around thisSinkSink<In,Mat>async(java.lang.String dispatcher, int inputBufferSize)Put an asynchronous boundary around thisSinkstatic <T> Sink<T,NotUsed>cancelled()ASinkthat immediately cancels its upstream after materialization.static <U,In>
 Sink<In,java.util.concurrent.CompletionStage<U>>collect(java.util.stream.Collector<In,?,U> collector)Creates a sink which materializes into aCompletionStagewhich will be completed with a result of the JavaCollectortransformation and reduction operations.static <T,U,M>
 Sink<T,java.util.List<M>>combine(java.util.List<? extends Graph<SinkShape<U>,M>> sinks, Function<java.lang.Integer,Graph<UniformFanOutShape<T,U>,NotUsed>> fanOutStrategy)Combine several sinks with fan-out strategy likeBroadcastorBalanceand returnsSink.static <T,U>
 Sink<T,NotUsed>combine(Sink<U,?> output1, Sink<U,?> output2, java.util.List<Sink<U,?>> rest, Function<java.lang.Integer,Graph<UniformFanOutShape<T,U>,NotUsed>> fanOutStrategy)Combine several sinks with fan-out strategy likeBroadcastorBalanceand returnsSink.static <T,U,M1,M2,M>
 Sink<T,M>combineMat(Sink<U,M1> first, Sink<U,M2> second, Function<java.lang.Integer,Graph<UniformFanOutShape<T,U>,NotUsed>> fanOutStrategy, Function2<M1,M2,M> matF)Combine two sinks with fan-out strategy likeBroadcastorBalanceand returnsSinkwith 2 outlets.static <T,M>
 Sink<T,java.util.concurrent.CompletionStage<M>>completionStageSink(java.util.concurrent.CompletionStage<Sink<T,M>> future)Turn aFuture[Sink]into a Sink that will consume the values of the source when the future completes successfully.<In2> Sink<In2,Mat>contramap(Function<In2,In> f)Transform this Sink by applying a function to each *incoming* upstream element before it is passed to theSinkstatic <In> Sink<In,java.util.concurrent.CompletionStage<java.lang.Boolean>>exists(Predicate<In> p)ASinkthat will test the given predicatepfor every received element and 1.static <U,In>
 Sink<In,java.util.concurrent.CompletionStage<U>>fold(U zero, Function2<U,In,U> f)ASinkthat will invoke the given function for every received element, giving it its previous output (or the givenzerovalue) and the element as input.static <U,In>
 Sink<In,java.util.concurrent.CompletionStage<U>>foldAsync(U zero, Function2<U,In,java.util.concurrent.CompletionStage<U>> f)ASinkthat will invoke the given asynchronous function for every received element, giving it its previous output (or the givenzerovalue) and the element as input.static <U,In>
 Sink<In,java.util.concurrent.CompletionStage<U>>foldWhile(U zero, Predicate<U> p, Function2<U,In,U> f)ASinkthat will invoke the given function for every received element, giving it its previous output (or the givenzerovalue) and the element as input.static <In> Sink<In,java.util.concurrent.CompletionStage<java.lang.Boolean>>forall(Predicate<In> p)ASinkthat will test the given predicatepfor every received element and 1.static <T> Sink<T,java.util.concurrent.CompletionStage<Done>>foreach(Procedure<T> f)ASinkthat will invoke the given procedure for each received element.static <T> Sink<T,java.util.concurrent.CompletionStage<Done>>foreachAsync(int parallelism, Function<T,java.util.concurrent.CompletionStage<java.lang.Void>> f)ASinkthat will invoke the given procedure asynchronously for each received element.static <T> Sink<T,java.util.concurrent.CompletionStage<Done>>foreachParallel(int parallel, Procedure<T> f, scala.concurrent.ExecutionContext ec)Deprecated.Use `foreachAsync` instead, it allows you to choose how to run the procedure, by calling some other API returning a CompletionStage or using CompletableFuture.supplyAsync.static <T,M>
 Sink<T,M>fromGraph(Graph<SinkShape<T>,M> g)A graph with the shape of a sink logically is a sink, this method makes it so also in type.static <T,M>
 Sink<T,java.util.concurrent.CompletionStage<M>>fromMaterializer(java.util.function.BiFunction<Materializer,Attributes,Sink<T,M>> factory)Defers the creation of aSinkuntil materialization.static <In> Sink<In,NotUsed>fromSubscriber(org.reactivestreams.Subscriber<In> subs)Helper to createSinkfromSubscriber.AttributesgetAttributes()static <In> Sink<In,java.util.concurrent.CompletionStage<In>>head()ASinkthat materializes into aCompletionStageof the first value received.static <In> Sink<In,java.util.concurrent.CompletionStage<java.util.Optional<In>>>headOption()ASinkthat materializes into aCompletionStageof the optional first value received.static <T> Sink<T,java.util.concurrent.CompletionStage<Done>>ignore()ASinkthat will consume the stream and discard the elements.static <In> Sink<In,java.util.concurrent.CompletionStage<In>>last()ASinkthat materializes into aCompletionStageof the last value received.static <In> Sink<In,java.util.concurrent.CompletionStage<java.util.Optional<In>>>lastOption()ASinkthat materializes into aCompletionStageof the optional last value received.static <T,M>
 Sink<T,java.util.concurrent.CompletionStage<M>>lazyCompletionStageSink(Creator<java.util.concurrent.CompletionStage<Sink<T,M>>> create)Defers invoking thecreatefunction to create a future sink until there is a first element passed from upstream.static <T,M>
 Sink<T,java.util.concurrent.CompletionStage<M>>lazyInit(Function<T,java.util.concurrent.CompletionStage<Sink<T,M>>> sinkFactory, Creator<M> fallback)Deprecated.Use 'Sink.lazyCompletionStageSink' in combination with 'Flow.prefixAndTail(1)' instead.static <T,M>
 Sink<T,java.util.concurrent.CompletionStage<java.util.Optional<M>>>lazyInitAsync(Creator<java.util.concurrent.CompletionStage<Sink<T,M>>> sinkFactory)Deprecated.Use 'Sink.lazyCompletionStageSink' instead.static <T,M>
 Sink<T,java.util.concurrent.CompletionStage<M>>lazySink(Creator<Sink<T,M>> create)Defers invoking thecreatefunction to create a sink until there is a first element passed from upstream.<Mat2> Sink<In,Mat2>mapMaterializedValue(Function<Mat,Mat2> f)Transform only the materialized value of this Sink, leaving all other properties as they were.Sink<In,Mat>named(java.lang.String name)Add anameattribute to this Sink.static <T> Sink<T,java.util.concurrent.CompletionStage<Done>>never()ASinkthat will always backpressure never cancel and never consume any elements from the stream.static <In> Sink<In,NotUsed>onComplete(Procedure<scala.util.Try<Done>> callback)ASinkthat when the flow is completed, either through a failure or normal completion, apply the provided function withSuccessorFailure.Pair<Mat,Sink<In,NotUsed>>preMaterialize(ClassicActorSystemProvider systemProvider)Materializes this Sink, immediately returning (1) its materialized value, and (2) a new Sink that can be consume elements 'into' the pre-materialized one.Pair<Mat,Sink<In,NotUsed>>preMaterialize(Materializer materializer)Materializes this Sink, immediately returning (1) its materialized value, and (2) a new Sink that can be consume elements 'into' the pre-materialized one.static <T> Sink<T,SinkQueueWithCancel<T>>queue()Creates aSinkthat is materialized as anpekko.stream.javadsl.SinkQueueWithCancel.static <T> Sink<T,SinkQueueWithCancel<T>>queue(int maxConcurrentPulls)Creates aSinkthat is materialized as anpekko.stream.javadsl.SinkQueueWithCancel.static <In> Sink<In,java.util.concurrent.CompletionStage<In>>reduce(Function2<In,In,In> f)ASinkthat will invoke the given function for every received element, giving it its previous output (from the second element) and the element as input.<M> MrunWith(Graph<SourceShape<In>,M> source, ClassicActorSystemProvider systemProvider)Connect thisSinkto aSourceand run it.<M> MrunWith(Graph<SourceShape<In>,M> source, Materializer materializer)Connect thisSinkto aSourceand run it.static <In> Sink<In,java.util.concurrent.CompletionStage<java.util.List<In>>>seq()ASinkthat keeps on collecting incoming elements until upstream terminates.static <T,M>
 Sink<T,java.util.concurrent.CompletionStage<M>>setup(java.util.function.BiFunction<ActorMaterializer,Attributes,Sink<T,M>> factory)Deprecated.Use 'fromMaterializer' instead.SinkShape<In>shape()The shape of a graph is all that is externally visible: its inlets and outlets.static <In> Sink<In,java.util.concurrent.CompletionStage<java.util.List<In>>>takeLast(int n)ASinkthat materializes into aCompletionStageofListcontaining the lastncollected elements.java.lang.StringtoString()org.apache.pekko.stream.impl.LinearTraversalBuildertraversalBuilder()INTERNAL API.Sink<In,Mat>withAttributes(Attributes attr)Replace the attributes of thisSinkwith the given ones.
 
- 
- 
- 
Method Detail- 
foldpublic static <U,In> Sink<In,java.util.concurrent.CompletionStage<U>> fold(U zero, Function2<U,In,U> f) ASinkthat will invoke the given function for every received element, giving it its previous output (or the givenzerovalue) and the element as input. The returnedCompletionStagewill be completed with value of the final function evaluation when the input stream ends, or completed withFailureif there is a failure is signaled in the stream.
 - 
foldWhilepublic static <U,In> Sink<In,java.util.concurrent.CompletionStage<U>> foldWhile(U zero, Predicate<U> p, Function2<U,In,U> f) ASinkthat will invoke the given function for every received element, giving it its previous output (or the givenzerovalue) and the element as input. The returnedCompletionStagewill be completed with value of the final function evaluation when the input stream ends, predicatepreturns false, or completed withFailureif there is a failure is signaled in the stream.- Since:
- 1.1.0
 
 - 
foldAsyncpublic static <U,In> Sink<In,java.util.concurrent.CompletionStage<U>> foldAsync(U zero, Function2<U,In,java.util.concurrent.CompletionStage<U>> f) ASinkthat will invoke the given asynchronous function for every received element, giving it its previous output (or the givenzerovalue) and the element as input. The returnedCompletionStagewill be completed with value of the final function evaluation when the input stream ends, or completed withFailureif there is a failure is signaled in the stream.
 - 
forallpublic static <In> Sink<In,java.util.concurrent.CompletionStage<java.lang.Boolean>> forall(Predicate<In> p) ASinkthat will test the given predicatepfor every received element and 1. completes and returnsCompletionStageoftrueif the predicate is true for all elements; 2. completes and returnsCompletionStageoftrueif the stream is empty (i.e. completes before signalling any elements); 3. completes and returnsCompletionStageoffalseif the predicate is false for any element.The materialized value CompletionStagewill be completed with the valuetrueorfalsewhen the input stream ends, or completed withFailureif there is a failure signaled in the stream.Adheres to the ActorAttributes.SupervisionStrategyattribute.'''Completes when''' upstream completes or the predicate preturnsfalse'''Backpressures when''' the invocation of predicate phas not yet completed'''Cancels when''' predicate preturnsfalse- Since:
- 1.1.0
 
 - 
existspublic static <In> Sink<In,java.util.concurrent.CompletionStage<java.lang.Boolean>> exists(Predicate<In> p) ASinkthat will test the given predicatepfor every received element and 1. completes and returnsCompletionStageoftrueif the predicate is true for any element; 2. completes and returnsCompletionStageoffalseif the stream is empty (i.e. completes before signalling any elements); 3. completes and returnsCompletionStageoffalseif the predicate is false for all elements.The materialized value CompletionStagewill be completed with the valuetrueorfalsewhen the input stream ends, or completed withFailureif there is a failure signaled in the stream.Adheres to the ActorAttributes.SupervisionStrategyattribute.'''Completes when''' upstream completes or the predicate preturnstrue'''Backpressures when''' the invocation of predicate phas not yet completed'''Cancels when''' predicate preturnstrue- Since:
- 1.1.0
 
 - 
collectpublic static <U,In> Sink<In,java.util.concurrent.CompletionStage<U>> collect(java.util.stream.Collector<In,?,U> collector) Creates a sink which materializes into aCompletionStagewhich will be completed with a result of the JavaCollectortransformation and reduction operations. This allows usage of Java streams transformations for reactive streams. TheCollectorwill trigger demand downstream. Elements emitted through the stream will be accumulated into a mutable result container, optionally transformed into a final representation after all input elements have been processed. TheCollectorcan also do reduction at the end. Reduction processing is performed sequentially.
 - 
reducepublic static <In> Sink<In,java.util.concurrent.CompletionStage<In>> reduce(Function2<In,In,In> f) ASinkthat will invoke the given function for every received element, giving it its previous output (from the second element) and the element as input. The returnedCompletionStagewill be completed with value of the final function evaluation when the input stream ends, or completed withFailureif there is a failure signaled in the stream.If the stream is empty (i.e. completes before signalling any elements), the reduce operator will fail its downstream with a NoSuchElementException, which is semantically in-line with that Scala's standard library collections do in such situations.
 - 
fromSubscriberpublic static <In> Sink<In,NotUsed> fromSubscriber(org.reactivestreams.Subscriber<In> subs) Helper to createSinkfromSubscriber.
 - 
cancelledpublic static <T> Sink<T,NotUsed> cancelled() ASinkthat immediately cancels its upstream after materialization.
 - 
ignorepublic static <T> Sink<T,java.util.concurrent.CompletionStage<Done>> ignore() ASinkthat will consume the stream and discard the elements.
 - 
neverpublic static <T> Sink<T,java.util.concurrent.CompletionStage<Done>> never() ASinkthat will always backpressure never cancel and never consume any elements from the stream.
 - 
asPublisherpublic static <T> Sink<T,org.reactivestreams.Publisher<T>> asPublisher(AsPublisher fanout) ASinkthat materializes into aPublisher.If fanoutistrue, the materializedPublisherwill support multipleSubscribers and the size of theinputBufferconfigured for this operator becomes the maximum number of elements that the fastestSubscribercan be ahead of the slowest one before slowing the processing down due to back pressure.If fanoutisfalsethen the materializedPublisherwill only support a singleSubscriberand reject any additionalSubscribers.
 - 
foreachpublic static <T> Sink<T,java.util.concurrent.CompletionStage<Done>> foreach(Procedure<T> f) ASinkthat will invoke the given procedure for each received element. The sink is materialized into aCompletionStagewhich will be completed withSuccesswhen reaching the normal end of the stream, or completed withFailureif there is a failure signaled in the stream.
 - 
foreachAsyncpublic static <T> Sink<T,java.util.concurrent.CompletionStage<Done>> foreachAsync(int parallelism, Function<T,java.util.concurrent.CompletionStage<java.lang.Void>> f) ASinkthat will invoke the given procedure asynchronously for each received element. The sink is materialized into aCompletionStagewhich will be completed withSuccesswhen reaching the normal end of the stream, or completed withFailureif there is a failure signaled in the stream.
 - 
foreachParallelpublic static <T> Sink<T,java.util.concurrent.CompletionStage<Done>> foreachParallel(int parallel, Procedure<T> f, scala.concurrent.ExecutionContext ec) Deprecated.Use `foreachAsync` instead, it allows you to choose how to run the procedure, by calling some other API returning a CompletionStage or using CompletableFuture.supplyAsync. Since Akka 2.5.17.ASinkthat will invoke the given procedure for each received element in parallel. The sink is materialized into aCompletionStage.If fthrows an exception and the supervision decision ispekko.stream.Supervision.StoptheCompletionStagewill be completed with failure.If fthrows an exception and the supervision decision ispekko.stream.Supervision.Resumeorpekko.stream.Supervision.Restartthe element is dropped and the stream continues.
 - 
onCompletepublic static <In> Sink<In,NotUsed> onComplete(Procedure<scala.util.Try<Done>> callback) ASinkthat when the flow is completed, either through a failure or normal completion, apply the provided function withSuccessorFailure.
 - 
headpublic static <In> Sink<In,java.util.concurrent.CompletionStage<In>> head() ASinkthat materializes into aCompletionStageof the first value received. If the stream completes before signaling at least a single element, the CompletionStage will be failed with aNoSuchElementException. If the stream signals an error before signaling at least a single element, the CompletionStage will be failed with the streams exception.See also <In>headOption().
 - 
headOptionpublic static <In> Sink<In,java.util.concurrent.CompletionStage<java.util.Optional<In>>> headOption() ASinkthat materializes into aCompletionStageof the optional first value received. If the stream completes before signaling at least a single element, the value of the CompletionStage will be an emptyOptional. If the stream signals an error errors before signaling at least a single element, the CompletionStage will be failed with the streams exception.See also <In>head().
 - 
lastpublic static <In> Sink<In,java.util.concurrent.CompletionStage<In>> last() ASinkthat materializes into aCompletionStageof the last value received. If the stream completes before signaling at least a single element, the CompletionStage will be failed with aNoSuchElementException. If the stream signals an error errors before signaling at least a single element, the CompletionStage will be failed with the streams exception.See also <In>lastOption(),<In>takeLast(int).
 - 
lastOptionpublic static <In> Sink<In,java.util.concurrent.CompletionStage<java.util.Optional<In>>> lastOption() ASinkthat materializes into aCompletionStageof the optional last value received. If the stream completes before signaling at least a single element, the value of the CompletionStage will be an emptyOptional. If the stream signals an error errors before signaling at least a single element, the CompletionStage will be failed with the streams exception.See also <In>head(),<In>takeLast(int).
 - 
takeLastpublic static <In> Sink<In,java.util.concurrent.CompletionStage<java.util.List<In>>> takeLast(int n) ASinkthat materializes into aCompletionStageofListcontaining the lastncollected elements.If the stream completes before signaling at least n elements, the CompletionStagewill complete with all elements seen so far. If the stream never completes theCompletionStagewill never complete. If there is a failure signaled in the stream theCompletionStagewill be completed with failure.
 - 
seqpublic static <In> Sink<In,java.util.concurrent.CompletionStage<java.util.List<In>>> seq() ASinkthat keeps on collecting incoming elements until upstream terminates. As upstream may be unbounded,Flow[T].takeor the stricterFlow[T].limit(and their variants) may be used to ensure boundedness. Materializes into aCompletionStageofSeq[T]containing all the collected elements.Listis limited toInteger.MAX_VALUEelements, this Sink will cancel the stream after having received that many elements.See also Flow.limit,Flow.limitWeighted,Flow.take,Flow.takeWithin,Flow.takeWhile
 - 
actorRefpublic static <In> Sink<In,NotUsed> actorRef(ActorRef ref, java.lang.Object onCompleteMessage) Sends the elements of the stream to the givenActorRef. If the target actor terminates the stream will be canceled. When the stream is completed successfully the givenonCompleteMessagewill be sent to the destination actor. When the stream is completed with failure apekko.actor.Status.Failuremessage will be sent to the destination actor.It will request at most maxInputBufferSizenumber of elements from upstream, but there is no back-pressure signal from the destination actor, i.e. if the actor is not consuming the messages fast enough the mailbox of the actor will grow. For potentially slow consumer actors it is recommended to use a bounded mailbox with zeromailbox-push-timeout-timeor use a rate limiting operator in front of thisSink.
 - 
actorRefWithBackpressurepublic static <In> Sink<In,NotUsed> actorRefWithBackpressure(ActorRef ref, java.lang.Object onInitMessage, java.lang.Object ackMessage, java.lang.Object onCompleteMessage, Function<java.lang.Throwable,java.lang.Object> onFailureMessage) Sends the elements of the stream to the givenActorRefthat sends back back-pressure signal. First element is alwaysonInitMessage, then stream is waiting for acknowledgement messageackMessagefrom the given actor which means that it is ready to process elements. It also requiresackMessagemessage after each stream element to make backpressure work.If the target actor terminates the stream will be canceled. When the stream is completed successfully the given onCompleteMessagewill be sent to the destination actor. When the stream is completed with failure - result ofonFailureMessage(throwable)message will be sent to the destination actor.
 - 
actorRefWithBackpressurepublic static <In> Sink<In,NotUsed> actorRefWithBackpressure(ActorRef ref, java.lang.Object onInitMessage, java.lang.Object onCompleteMessage, Function<java.lang.Throwable,java.lang.Object> onFailureMessage) Sends the elements of the stream to the givenActorRefthat sends back back-pressure signal. First element is alwaysonInitMessage, then stream is waiting for acknowledgement message from the given actor which means that it is ready to process elements. It also requires an ack message after each stream element to make backpressure work. This variant will consider any message as ack message.If the target actor terminates the stream will be canceled. When the stream is completed successfully the given onCompleteMessagewill be sent to the destination actor. When the stream is completed with failure - result ofonFailureMessage(throwable)message will be sent to the destination actor.
 - 
actorRefWithAckpublic static <In> Sink<In,NotUsed> actorRefWithAck(ActorRef ref, java.lang.Object onInitMessage, java.lang.Object ackMessage, java.lang.Object onCompleteMessage, Function<java.lang.Throwable,java.lang.Object> onFailureMessage) Deprecated.Use actorRefWithBackpressure insteadSends the elements of the stream to the givenActorRefthat sends back back-pressure signal. First element is alwaysonInitMessage, then stream is waiting for acknowledgement messageackMessagefrom the given actor which means that it is ready to process elements. It also requiresackMessagemessage after each stream element to make backpressure work.If the target actor terminates the stream will be canceled. When the stream is completed successfully the given onCompleteMessagewill be sent to the destination actor. When the stream is completed with failure - result ofonFailureMessage(throwable)message will be sent to the destination actor.
 - 
fromGraphpublic static <T,M> Sink<T,M> fromGraph(Graph<SinkShape<T>,M> g) A graph with the shape of a sink logically is a sink, this method makes it so also in type.
 - 
fromMaterializerpublic static <T,M> Sink<T,java.util.concurrent.CompletionStage<M>> fromMaterializer(java.util.function.BiFunction<Materializer,Attributes,Sink<T,M>> factory) 
 - 
setuppublic static <T,M> Sink<T,java.util.concurrent.CompletionStage<M>> setup(java.util.function.BiFunction<ActorMaterializer,Attributes,Sink<T,M>> factory) Deprecated.Use 'fromMaterializer' instead. Since Akka 2.6.0.
 - 
combinepublic static <T,U> Sink<T,NotUsed> combine(Sink<U,?> output1, Sink<U,?> output2, java.util.List<Sink<U,?>> rest, Function<java.lang.Integer,Graph<UniformFanOutShape<T,U>,NotUsed>> fanOutStrategy) Combine several sinks with fan-out strategy likeBroadcastorBalanceand returnsSink.
 - 
combineMatpublic static <T,U,M1,M2,M> Sink<T,M> combineMat(Sink<U,M1> first, Sink<U,M2> second, Function<java.lang.Integer,Graph<UniformFanOutShape<T,U>,NotUsed>> fanOutStrategy, Function2<M1,M2,M> matF) Combine two sinks with fan-out strategy likeBroadcastorBalanceand returnsSinkwith 2 outlets.- Since:
- 1.1.0
 
 - 
combinepublic static <T,U,M> Sink<T,java.util.List<M>> combine(java.util.List<? extends Graph<SinkShape<U>,M>> sinks, Function<java.lang.Integer,Graph<UniformFanOutShape<T,U>,NotUsed>> fanOutStrategy) Combine several sinks with fan-out strategy likeBroadcastorBalanceand returnsSink. The fanoutGraph's outlets size must match the provides sinks'.- Since:
- 1.1.0
 
 - 
queuepublic static <T> Sink<T,SinkQueueWithCancel<T>> queue(int maxConcurrentPulls) Creates aSinkthat is materialized as anpekko.stream.javadsl.SinkQueueWithCancel.pekko.stream.javadsl.SinkQueueWithCancel.pullmethod is pulling element from the stream and returnsCompletionStage[Option[T}.CompletionStagecompletes when element is available.Before calling pull method second time you need to ensure that number of pending pulls is less then maxConcurrentPullsor wait until some of the previous Futures completes. Pull returns Failed future with ''IllegalStateException'' if there will be more thenmaxConcurrentPullsnumber of pending pulls.Sinkwill request at most number of elements equal to size ofinputBufferfrom upstream and then stop back pressure. You can configure size of input buffer by usingSink.withAttributesmethod.For stream completion you need to pull all elements from pekko.stream.javadsl.SinkQueueWithCancelincluding last None as completion marker- See Also:
- pekko.stream.javadsl.SinkQueueWithCancel
 
 - 
queuepublic static <T> Sink<T,SinkQueueWithCancel<T>> queue() Creates aSinkthat is materialized as anpekko.stream.javadsl.SinkQueueWithCancel.pekko.stream.javadsl.SinkQueueWithCancel.pullmethod is pulling element from the stream and returnsCompletionStage[Option[T}.CompletionStagecompletes when element is available.Before calling pull method second time you need to wait until previous CompletionStage completes. Pull returns Failed future with ''IllegalStateException'' if previous future has not yet completed. Sinkwill request at most number of elements equal to size ofinputBufferfrom upstream and then stop back pressure. You can configure size of input buffer by usingSink.withAttributesmethod.For stream completion you need to pull all elements from pekko.stream.javadsl.SinkQueueWithCancelincluding last None as completion marker- See Also:
- pekko.stream.javadsl.SinkQueueWithCancel
 
 - 
lazyInitpublic static <T,M> Sink<T,java.util.concurrent.CompletionStage<M>> lazyInit(Function<T,java.util.concurrent.CompletionStage<Sink<T,M>>> sinkFactory, Creator<M> fallback) Deprecated.Use 'Sink.lazyCompletionStageSink' in combination with 'Flow.prefixAndTail(1)' instead. Since Akka 2.6.0.Creates a realSinkupon receiving the first element. InternalSinkwill not be created if there are no elements, because of completion or error.If upstream completes before an element was received then the Futureis completed with the value created by fallback. If upstream fails before an element was received,sinkFactorythrows an exception, or materialization of the internal sink fails then theFutureis completed with the exception. Otherwise theFutureis completed with the materialized value of the internal sink.
 - 
lazyInitAsyncpublic static <T,M> Sink<T,java.util.concurrent.CompletionStage<java.util.Optional<M>>> lazyInitAsync(Creator<java.util.concurrent.CompletionStage<Sink<T,M>>> sinkFactory) Deprecated.Use 'Sink.lazyCompletionStageSink' instead. Since Akka 2.6.0.Creates a realSinkupon receiving the first element. InternalSinkwill not be created if there are no elements, because of completion or error.If upstream completes before an element was received then the Futureis completed withNone. If upstream fails before an element was received,sinkFactorythrows an exception, or materialization of the internal sink fails then theFutureis completed with the exception. Otherwise theFutureis completed with the materialized value of the internal sink.
 - 
completionStageSinkpublic static <T,M> Sink<T,java.util.concurrent.CompletionStage<M>> completionStageSink(java.util.concurrent.CompletionStage<Sink<T,M>> future) Turn aFuture[Sink]into a Sink that will consume the values of the source when the future completes successfully. If theFutureis completed with a failure the stream is failed.The materialized future value is completed with the materialized value of the future sink or failed with a NeverMaterializedExceptionif upstream fails or downstream cancels before the future has completed.
 - 
lazySinkpublic static <T,M> Sink<T,java.util.concurrent.CompletionStage<M>> lazySink(Creator<Sink<T,M>> create) Defers invoking thecreatefunction to create a sink until there is a first element passed from upstream.The materialized future value is completed with the materialized value of the created sink when that has successfully been materialized. If the createfunction throws or returns or the stream fails to materialize, in this case the materialized future value is failed with apekko.stream.NeverMaterializedException.
 - 
lazyCompletionStageSinkpublic static <T,M> Sink<T,java.util.concurrent.CompletionStage<M>> lazyCompletionStageSink(Creator<java.util.concurrent.CompletionStage<Sink<T,M>>> create) Defers invoking thecreatefunction to create a future sink until there is a first element passed from upstream.The materialized future value is completed with the materialized value of the created sink when that has successfully been materialized. If the createfunction throws or returns a future that is failed, or the stream fails to materialize, in this case the materialized future value is failed with apekko.stream.NeverMaterializedException.
 - 
shapepublic SinkShape<In> shape() Description copied from interface:GraphThe shape of a graph is all that is externally visible: its inlets and outlets.
 - 
traversalBuilderpublic org.apache.pekko.stream.impl.LinearTraversalBuilder traversalBuilder() Description copied from interface:GraphINTERNAL API.Every materializable element must be backed by a stream layout module - Specified by:
- traversalBuilderin interface- Graph<In,Mat>
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 - 
runWithpublic <M> M runWith(Graph<SourceShape<In>,M> source, ClassicActorSystemProvider systemProvider) Connect thisSinkto aSourceand run it.Note that the ActorSystemcan be used as thesystemProviderparameter.
 - 
runWithpublic <M> M runWith(Graph<SourceShape<In>,M> source, Materializer materializer) Connect thisSinkto aSourceand run it.
 - 
contramappublic <In2> Sink<In2,Mat> contramap(Function<In2,In> f) Transform this Sink by applying a function to each *incoming* upstream element before it is passed to theSink'''Backpressures when''' original Sinkbackpressures'''Cancels when''' original Sinkbackpressures- Since:
- 1.1.0
 
 - 
mapMaterializedValuepublic <Mat2> Sink<In,Mat2> mapMaterializedValue(Function<Mat,Mat2> f) Transform only the materialized value of this Sink, leaving all other properties as they were.
 - 
preMaterializepublic Pair<Mat,Sink<In,NotUsed>> preMaterialize(ClassicActorSystemProvider systemProvider) Materializes this Sink, immediately returning (1) its materialized value, and (2) a new Sink that can be consume elements 'into' the pre-materialized one.Useful for when you need a materialized value of a Sink when handing it out to someone to materialize it for you. Note that the ActorSystemcan be used as thesystemProviderparameter.
 - 
preMaterializepublic Pair<Mat,Sink<In,NotUsed>> preMaterialize(Materializer materializer) Materializes this Sink, immediately returning (1) its materialized value, and (2) a new Sink that can be consume elements 'into' the pre-materialized one.Useful for when you need a materialized value of a Sink when handing it out to someone to materialize it for you. Prefer the method taking an ActorSystem unless you have special requirements. 
 - 
withAttributespublic Sink<In,Mat> withAttributes(Attributes attr) Replace the attributes of thisSinkwith the given ones. If this Sink is a composite of multiple graphs, new attributes on the composite will be less specific than attributes set directly on the individual graphs of the composite.- Specified by:
- withAttributesin interface- Graph<In,Mat>
 
 - 
addAttributespublic Sink<In,Mat> addAttributes(Attributes attr) Add the given attributes to thisSink. If the specific attribute was already present on this graph this means the added attribute will be more specific than the existing one. If this Sink is a composite of multiple graphs, new attributes on the composite will be less specific than attributes set directly on the individual graphs of the composite.- Specified by:
- addAttributesin interface- Graph<In,Mat>
 
 - 
asyncpublic Sink<In,Mat> async(java.lang.String dispatcher) Put an asynchronous boundary around thisSink
 - 
asyncpublic Sink<In,Mat> async(java.lang.String dispatcher, int inputBufferSize) Put an asynchronous boundary around thisSink
 - 
getAttributespublic Attributes getAttributes() - Specified by:
- getAttributesin interface- Graph<In,Mat>
 
 
- 
 
-