Quantcast
Channel: Akka Libraries - Discussion Forum for Akka technologies
Viewing all articles
Browse latest Browse all 1362

How to shutdown a dynamic stream in MergeHub

$
0
0

Hi,

I can not shutdown a dynamic stream in MergeHub. A code example is bellow

val consumer = Sink.foreach(println) 

val mergeHub = MergeHub.source[JsValue](perProducerBufferSize = 16)
val runnableGraph: RunnableGraph[Sink[JsValue, NotUsed]] =
  MergeHub.source[JsValue](perProducerBufferSize = 16).to(consumer)


val toConsumer = runnableGraph.run()

Now, I create a dynamic stream

val (done,killSwitch) = Source.repeat(JsString("Test"))
  .throttle(1, 1 seconds)
  .viaMat(KillSwitches.single)(Keep.both)
  .toMat(toConsumer)(Keep.left)
  .run()    

Calling killSwitch.shutdown() or killSwitch.abort(new Exception(“Stop stream”)) will not stop the dynamic stream.

Is it possible to stop this dynamic stream?

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 1362