Regarding that suggestion, here is a code sample on how you might 
accomplish the case of a graph stage that registers for updates from an 
actor:

https://github.com/Keenworks/SampleActorStage

Curt Siffert

On Thursday, June 8, 2017 at 4:27:43 AM UTC-7, Akka Team wrote:
>
> One way would be mapAsync(1)(elem => 
> ask-actor-and-combine-elem-with-token). If asking for every element is too 
> expensive you could make a custom graph stage which asks the actor on 
> materialisation to get the first token, but then also registers for updates 
> from the actor, that can be done using the stage actor ref (see docs here: 
> http://doc.akka.io/docs/akka/current/scala/stream/stream-customize.html#integration-with-actors
> )
>
> --
> Johan
> Akka Team
>
> On Thu, Jun 1, 2017 at 7:21 PM, Mohnish Kodnani <mohnish...@gmail.com 
> <javascript:>> wrote:
>
>> Hi , 
>> I have the following use case that I want to model using akka streams and 
>> I am new to akka streams so would like to know how/what is the best way to 
>> model it. 
>>
>> I have a kafka consumer which reads from one topic massages the message 
>> and sends it to a RESTful external service. 
>> This external restful service takes a token that needs to be sent with 
>> every message in the header. This token expires every roughly 24 hours.
>>
>> I was thinking of creating an FSM actor that will act as a Token Manager. 
>> It will be in Active state where it can send the current token on receiving 
>> say a GetToken message. Then every 24 hours it receives a scheduled event 
>> for FetchToken, then it will go into Fetching mode, where it will retrieve 
>> a new token from another service and in that state it should keep queuing 
>> the requests for GetToken.
>>
>> Now, how do i hook this actor (TokenManager) into my stream so that it 
>> can provide a token for every message from kafka but block the stream until 
>> it gets a new token when it expires. 
>> Or if there is another solution to what I am thinking instead of creating 
>> a separate actor. 
>>
>> Thanks
>> Mohnish.
>>
>>
>> -- 
>> >>>>>>>>>> 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+...@googlegroups.com <javascript:>.
>> To post to this group, send email to akka...@googlegroups.com 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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