Hi,

Thanks for the response. Eventually I used the first option which is by 
using TimerGraphStageLogic.

Whenever there is no data, the AsyncCallBack calls scheduleOnce() with some 
poll interval and the onTimer() delegates to the method that does a DB 
fetch.

It's a nice, clean solution, and there's a good example of it in the new Akka 
blog 
<http://blog.akka.io/integrations/2016/08/29/connecting-existing-apis#timed-and-non-blocking-polling>
 
under the "Timed and Non-blocking polling" section.

On Thursday, September 8, 2016 at 9:59:42 AM UTC+3, gor...@8kdata.com wrote:
>
> Hi there,
>
> I am just a newbie on Akka, but as far as I know, you have to expect to 
> not recive a new call to onPull until you push something. So you need an 
> external "agent" to wake up your GraphStage. One option is to use a timer 
> that each time it is executed, it queries the database and, if something is 
> found and the outlet is ready (on java DSL, which is the one I use, the 
> method is called *isAvailable*). Another option could be to use the 
> reactive mongodb driver, open a tailable cursor and then all the magic 
> should be automatically done for you. This second option sounds better, but 
> I have never used that driver and I don't know if you can use a tailable 
> cursor.
>
> If you decide to use the polling version, there I recommend you to check 
> the samples on the documentation or even better, to check the Akka Stream 
> source code. I am not used to read scala code, but I was able to understand 
> the standard flow stages on the github repository, so I am sure you can do 
> it.
>
> Bests,
>
> Gonzalo
>
> El miércoles, 7 de septiembre de 2016, 10:37:07 (UTC+2), Ori Popowski 
> escribió:
>>
>> Hi,
>>
>> We have a GraphStage[SourceShape[?]] with a simple OutHandler which does 
>> the following:
>>
>>    1. Finds a document in MongoDB
>>    2. Pushes that document to the outlet using push()
>>
>> It's possible that the source will not find any documents in the DB at a 
>> given moment, but new documents may be arrive later.
>>
>>
>> The problem is that after the first time onPull is called and doesn't 
>> push anything to the outlet, then even when new documents are available in 
>> the DB, they won't be pushed later.
>>
>>
>> It's like the notion of a demand from downstream just gets lost. I'm 
>> obviously missing some API capability to deal with such situation, but I 
>> cannot find any material on this.
>>
>>
>> How should we solve such a problem?
>>
>>
>> Thanks
>>
>

-- 
>>>>>>>>>>      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