Java Code Examples for akka.stream.javadsl.Sink#foreach()
The following examples show how to use
akka.stream.javadsl.Sink#foreach() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DispatcherActor.java From ditto with Eclipse Public License 2.0 | 5 votes |
private static Sink<ImmutableDispatch, ?> searchActorSink(final ActorRef pubSubMediator, final PreEnforcer preEnforcer) { return Sink.foreach(dispatchToPreEnforce -> preEnforce(dispatchToPreEnforce, preEnforcer, dispatch -> pubSubMediator.tell( DistPubSubAccess.send(SEARCH_ACTOR_PATH, dispatch.getMessage()), dispatch.getSender()) ) ); }
Example 2
Source File: DispatcherActor.java From ditto with Eclipse Public License 2.0 | 5 votes |
private static Sink<ImmutableDispatch, ?> thingsAggregatorSink(final PreEnforcer preEnforcer) { return Sink.foreach(dispatchToPreEnforce -> preEnforce(dispatchToPreEnforce, preEnforcer, dispatch -> dispatch.thingsAggregatorActor.tell(dispatch.getMessage(), dispatch.getSender()) ) ); }
Example 3
Source File: WebSocketRoute.java From ditto with Eclipse Public License 2.0 | 5 votes |
private Graph<SinkShape<Either<StreamControlMessage, Signal>>, ?> getStreamControlOrSignalSink() { return Sink.foreach(either -> { final Object streamControlMessageOrSignal = either.isLeft() ? either.left().get() : either.right().get(); streamingActor.tell(streamControlMessageOrSignal, ActorRef.noSender()); }); }
Example 4
Source File: KafkaPublisherActor.java From ditto with Eclipse Public License 2.0 | 5 votes |
private static Sink<ProducerMessage.Results<String, String, PassThrough>, CompletionStage<Done>> publishSuccessSink() { // basically, we don't know if the 'publish' will succeed or fail. We would need to write our own // GraphStage actor for Kafka and MQTT, since alpakka doesn't provide this useful information for us. return Sink.foreach(results -> { final ConnectionMonitor connectionMonitor = results.passThrough().connectionMonitor; connectionMonitor.success(results.passThrough().externalMessage); }); }
Example 5
Source File: DispatcherActor.java From ditto with Eclipse Public License 2.0 | 4 votes |
@Override protected Sink<ImmutableDispatch, ?> processedMessageSink() { return Sink.foreach(dispatch -> logger.withCorrelationId(dispatch.getMessage()) .warning("Unhandled Message in DispatcherActor: <{}>", dispatch)); }
Example 6
Source File: AkkaApplication.java From reactive-code-workshop with Apache License 2.0 | 2 votes |
/** * .alsoTo(getDebugSink()) * @return a sink that prints all elements it has been passed */ private <T> Sink<T,CompletionStage<Done>> getDebugSink() { return Sink.foreach(t -> System.out.println(t)); }