Good catch, thanks Endre :-)

-- 
Cheers,
Konrad `ktoso` Malawski
Akka @ Typesafe

On 16 September 2015 at 12:46:53, Endre Varga ([email protected]) wrote:



On Wed, Sep 16, 2015 at 12:42 PM, Konrad Malawski 
<[email protected]> wrote:
Hi there Anil,
it's an explicit design choice that Akka Streams have made, to make all fan-in 
and fan-out operations explicit.

This is half true, the dynamic, non-explicit fan-out part can be done with 
Sink.fanoutPublisher.

However, the RS spec clearly disallows subscribing a Subscriber to two 
Publishers at the same time: Rule 2.12 
https://github.com/reactive-streams/reactive-streams-jvm/tree/v1.0.0#specification

-Endre
 
Also, the Reactive Streams protocol you reverted to (publisher / subscriber) is 
defined on a 1:1 basis, 
as Endre mentioned, it should have actually thrown an exception when you called 
the subscribe the second time - we'll need to investigate, could be a bug.

It's of course possible and very core to Akka Streams to perform fan-in / 
fan-out operations, and here's how to do it:
http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0/scala/stream-graphs.html#Constructing_Flow_Graphs

In your case you could use Merge or Concat, and it would result in different 
pulling behaviour.
Imagine the question: "I have 2 upstreams... HOW do I want to consume them? In 
any order? Do I prefer one of them? Do I want to consume from each one element 
at a time and `zip` them together?". This is why making these operations 
explicit is so powerful, you get to chose how the pulling is performed.

Hope this helps!

-- 
Cheers,
Konrad `ktoso` Malawski
Akka @ Typesafe

On 16 September 2015 at 12:35:14, anil chalil ([email protected]) wrote:

Hi everybody


  
object Main2 extends App{
  implicit val system = ActorSystem("streamakka")
  implicit val materializer = ActorMaterializer()
  val sub1=Source.subscriber[String].to(Sink.foreach(println)).run()

  val pub1=Source.repeat("p1").runWith(Sink.publisher)
  val pub2=Source.repeat("p2").runWith(Sink.publisher)

  pub1.subscribe(sub1)
  pub2.subscribe(sub1)
}


I just wrote simple code. There are two publishers and one subscriber. I am 
using reactive stream api because in my app i want to dynamically subscriber 
client connections(Publishers) to a single subscriber(actually a flow 
implemented with akka stream again). In my machine sometimes it just write

p1
p1
p1
p1

or

p2
p2
p2
p2

sometimes it just writes lots of p1 or p2 values. Am i missing something?



 

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

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

Reply via email to