Hi, On Mon, May 11, 2015 at 9:43 AM, akka-streams-beginner <[email protected]> wrote:
> Hi Endre, > > I was able to implement everything like you suggested by providing a > function to combine the mat values of the 2 sources into 1. But is it > possible to implement this for a list of sources? I mean, not a finite > number of sources (I believe that can be done by using the odd .closed2-21 > methods in GraphCreate), but with a list of source, built dynamically in > run time? > No, it is not possible. The reason is that every Graph has a single materialized type M. If you don't pass explicitly the imported graphs as arguments, then it is not possible to express the materialized types of them to the compiler. The only way would be to use HLists, but we wanted to avoid that. -Endre > > > On Friday, May 8, 2015 at 12:06:18 PM UTC+3, Akka Team wrote: >> >> Hi, >> >> On Wed, May 6, 2015 at 3:49 PM, akka-streams-beginner <[email protected]> >> wrote: >> >>> I posted this question to stackoverflow ( >>> http://stackoverflow.com/questions/30077766/how-to-attach-multiple-actors-as-sources-to-an-akka-stream), >>> but then was pointed to this group, so I'll ask here: >>> >>> I am trying to build and run an akka stream flow (in Java DSL) with 2 >>> actors as sources, then a merge junction and then 1 sink: >>> >>> Source<Integer, ActorRef> src1 = Source.actorRef(100, >>> OverflowStrategy.backpressure()); >>> Source<Integer, ActorRef> src2 = Source.actorRef(100, >>> OverflowStrategy.backpressure()); >>> Sink<Integer, BoxedUnit> sink = >>> Flow.of(Integer.class).to(Sink.foreach(System.out::println)); >>> >>> RunnableFlow<BoxedUnit> closed = FlowGraph.factory().closed(sink, (b, >>> out) -> { >>> UniformFanInShape<Integer, Integer> merge = >>> b.graph(Merge.<Integer>create(2)); >>> b.from(src1).via(merge).to(out); >>> b.from(src2).to(merge); >>> }); >>> >>> closed.run(mat); >>> >>> My question is how do I obtain ActorRef references to the source actors >>> in order to send them messages? In case of 1 actor, I wouldn't be using >>> graph builder, and then the .run() or runWith() method would return the >>> ActorRef object. But what to do in case of many source actors? Is it even >>> possible to materialize such a flow? >>> >> >> You should pass src1, src2 as parameters to the .closed() method, and >> also define a function how to combine the materialized value of src1, src2 >> and sink. I.e. instead of just passing sink, you pass the sources, too. >> This way you can include all materialized values in a final value. >> >> -Endre >> >> >>> 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 [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/d/optout. >>> >> >> >> >> -- >> Akka Team >> Typesafe - Reactive apps on the JVM >> Blog: letitcrash.com >> Twitter: @akkateam >> > -- > >>>>>>>>>> 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 http://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 [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/d/optout.
