Hello,

1) I'm starting to play with akka, and i was wondering how I could get one 
result from different APIs, let me explain:

I try to get reviews on movies from different APIs because some APIs may 
not know one movie, or not have any data on some TV shows... 

I'd like to send a broadcast message to a pannel of actors, and for exemple 
keep the first response or wait for a while and keep the response from the 
most trusted API. (I could convert trust to timeout for exemple, the more I 
trust an API the greater the timeout is, but after that I need to get the 
response I trust the most among all responses).

I know ScatterGatherFirstCompletedRouter could make sens, but if I'm not 
wrong, it can only be used with one actor.

And i'd like each API actor to be able to manage alone whether it can 
process the message: for instance, "I'm an movie API, I can't process TV 
shows". But I don't know what to do if there is no result.

That is my first problem.


2) Here's my other probelem. I ask an actor to return a sequence of movies 
and ask each movie to send a message to other actors to get complementary 
data, because i made that 

 case WatchEveningShows(day : Date) => 
    val originalSender = sender
    implicit val ec: ExecutionContext = context.dispatcher
    //technique de la doc akka
        

                //return a list of programme
 val futurJson  = for {
    programmes <- (XmlTvProviderActor.xmlTvProviderActor ? 
WatchEveningShows(day)).mapTo[Shows]
    
} yield programmes.programmes.map(xmlProgramme =>{ 
TvProgrammeFactory.makeTvProgrammeFromXmlProgramme(xmlProgramme)}) //transform 
the data to OO
                
futurJson map (programmes => {

                        //Here a ask for each programme 
val futurProg = Future.sequence(
    programmes.map(
        x => (XmlTvProviderActor.xmlTvProviderActor ? 
GetChannelName(x.channel)).
         mapTo[ChannelName].
         map({y => 
                                                         // i'm not sure if 
is it the right way , very very not sure.
           x.channel = y.name //set the true value of each object 
           x // return the programme in the seq
           })
         )
        )
        
val futurNote = Future.sequence(
    programmes.map(
        x => (BetaserieActor.betaserieActor ?  GetNote(x)).
         mapTo[Double].
         map({y => 
           x.rating = y //set the true value of each object
           x // return the programme in the seq
           })
         )
        )
 for {
   a <- futurProg
   b <- futurNote
 } yield originalSender ! JSonShows(Json.toJson(b.sortBy(x 
=>(x.rating)).reverse.map(x 
=>Json.toJson(x)))) 
    
  })


But i'm wondering if there is not a more proper way to do this composition.



-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: http://akka.io/faq/
>>>>>>>>>>      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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to