Hi,

I don't know if there is any built-in graph that does this, but you can 
implement your own graph stage for this fairly easily.
You just need a stage with an Option[Value], in the onPush you either push 
the value downstream or store it, and in any case you pull. In the onPull 
you just have to check the option, and if it's defined push it (you will 
also need to pull the first time onPull is called to "seed" the demand). 

HTH,
Tal

On Thursday, January 25, 2018 at 9:03:11 AM UTC+2, [email protected] 
wrote:
>
> Hello,
>
> We are having a requirement that if a consumer is slower than producer 
> then discard all the elements that cannot be consumed and whenever the 
> consumer gets ready, feed the latest element from producer.
>
> We tried an approach as follows:
>
> Source.actorRef(0, OverflowStrategy.dropHead)       // actor receives data 
>> at every 10 milliseconds
>
> .runWith {
>>    println("data received")
>>    Thread.sleep(1000)               // mimic consumer processing data in 
>> every 1 second
>> }
>
>
> We shrank the buffer size to 1 (minimal possible) with following settings
>
> private val actorMaterializerSettings = ActorMaterializerSettings(
>> actorSystem).withInputBuffer(1, 1)
>
>
> With this buffer size, Sink pulls data 1 to consume and data 2 to put in 
> buffer at initialization.
>
> While data 1 is getting processed we are dropping data from producer.
>
> When data 1 gets processed after 1000 milliseconds (1 second) ideally I 
> should receive data 10 (and drop 2 - 9 as consumer is slow) but instead I 
> receive data 2 from the buffer. data 2 in our domain is extremely useless 
> as it is stale.
>
> Is there a way to disable buffer at Sink totally and always pull latest 
> data from Source ?
>
>
>

-- 
>>>>>>>>>>      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 [email protected].
To post to this group, send email to [email protected].
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