Consume all elements but discards them.
Consume all elements but discards them. Useful when a stream has to be consumed but there is no use to actually do anything with the elements in the
Sink. Processing of the elements may occur in the
This examples reads lines from a file, saves them to a database, and stores the database identifiers in another file. The stream is run with
Sink.ignore because all processing of the elements have been performed by the preceding stream operators.
val lines: Source[String, NotUsed] = readLinesFromFile()
val databaseIds: Source[UUID, NotUsed] =
lines.mapAsync(1)(line => saveLineToDatabase(line))
databaseIds.mapAsync(1)(uuid => writeIdToFile(uuid)).runWith(Sink.ignore)
Source<String, NotUsed> lines = readLinesFromFile();
Source<UUID, NotUsed> databaseIds = lines.mapAsync(1, line -> saveLineToDatabase(line));
databaseIds.mapAsync(1, uuid -> writeIdToFile(uuid)).runWith(Sink.ignore(), system);
Reactive Streams semantics
Found an error in this documentation? The source code for this page can be found here
Please feel free to edit and contribute a pull request.