How to slow down the manufacturer at Akka-Streams

I am trying to solve a problem with akka-streams. I want my original producer to constantly collect the queue / mongodb collection and make it within the configured interval. What is the usual practice for its implementation?

+4
source share
2 answers

Do you mean a fixed time interval?

Start with Source.tick(...).map(loadFromMongo)?

Insert conflate which removes ticks to prevent db request more often than downstream can handle if that is what you want.

+4
source

In addition, there is a concept called a throttle. It can be used as follows:

Source(...).throttle(50, 1.second, 1, ThrottleMode.Shaping)

, , 50 . : http://doc.akka.io/docs/akka/current/scala/stream/stream-quickstart.html#Time-Based_Processing

0

All Articles