Consume all elements but discards them.

Sink operators




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 Source/Flow.


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.

sourceval 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)
sourceSource<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

cancels never

backpressures never

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.