Whatever Flow your graph(system) method call returns is the culprit here. I
don't know what that is, but we can assume it is not rate-limited in any
way. I'm guessing it is wrapping an Actor. If that's the case, I would
consider interacting with the Actor using the "akka.pattern.ask" pattern,
and using Flow.mapAsync with a finite "parallelism" value to integrate it
into your flow.

Brian Maso

On Tue, Nov 13, 2018 at 3:08 AM <4915374...@gmail.com> wrote:

> object stream2iter extends Iterator[(LogSequenceNumber, String)] {
>   override def next: (LogSequenceNumber, String) = {
>     try {
>       val msg = stream.read
>       //println(msg)
>       val offset = msg.arrayOffset
>       val src = msg.array
>       val len = src.length - offset
>       inprogressbyte.set(len)
>       val log = new String(src, offset, len)
>       logger.debug(log)
>       val tmpLSN = stream.getLastReceiveLSN
>
>       (tmpLSN, log)
>     } catch {
>       case e: Throwable =>
>         println(e)
>         (LogSequenceNumber.INVALID_LSN, "")
>     }
>   }
>
>   override def hasNext: Boolean = !stream.isClosed
> }
>
> val srcStream: Source[(LogSequenceNumber, String), NotUsed] = 
> Source.fromIterator(() => stream2iter)
>
>
> val sink: Sink[LogRecord, Future[Done]] = Sink.foreach(log => {
>   logger.debug(s"LSN: ${log.lsn}, target: ${log.target.fullname}")
>   if (log.lsn != LogSequenceNumber.INVALID_LSN)
>     lastReceiveLSN = log.lsn
>   stream.setAppliedLSN(lastReceiveLSN)
>   stream.setFlushedLSN(lastReceiveLSN)
> })
>
> val totalG: RunnableGraph[NotUsed] = srcStream.via(graph(system)).to(sink)
> val res = totalG.run()
>
>
> // Now, stream.read is too fast(producer is fast, but consumer is slower),so 
> can I use back pressure
>
> // in iterator and can someone help me :-)
>
> --
>
> *****************************************************************************************************
> ** New discussion forum: https://discuss.akka.io/ replacing akka-user
> google-group soon.
> ** This group will soon be put into read-only mode, and replaced by
> discuss.akka.io
> ** More details:
> https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced
>
> *****************************************************************************************************
> >>>>>>>>>>
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
*****************************************************************************************************
** New discussion forum: https://discuss.akka.io/ replacing akka-user 
google-group soon.
** This group will soon be put into read-only mode, and replaced by 
discuss.akka.io
** More details: https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced
*****************************************************************************************************
>>>>>>>>>> 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to