GitHub user ptrdom added a comment to the discussion: Artifical back pressure 
on JDBC projections

@rsmidt Maybe `sourceProvider` could be wrapped to add 
[throttling](https://pekko.apache.org/docs/pekko/current/stream/operators/Source-or-Flow/throttle.html)
 to the source?
```scala
JdbcProjection.atLeastOnce(
    ProjectionId.of(PROJECTION_NAME, tag),
    new SourceProvider[Long, Envelope] {
        val wrapped = sourceProvider

        override def source(offset: () => Future[Option[Long]]): 
Future[Source[Envelope, NotUsed]] =
          wrapped.source(offset).map(_.throttle(1, 1.second))

        override def extractOffset(envelope: Envelope): Long = 
wrapped.extractOffset(envelope)

        override def extractCreationTime(envelope: Envelope): Long = 
wrapped.extractOffset(envelope)
      },
    ...
)
```

GitHub link: 
https://github.com/apache/pekko/discussions/2431#discussioncomment-14893907

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to