Because in your actor example you're confusing the materialization of one
flow with the returning of another.

On Fri, Nov 11, 2016 at 11:29 AM, Alexandre Masselot <
[email protected]> wrote:

> Hello,
>
> I'm a bit stuck and seeking for help;)
> A play controller should be producing Server Side Events, tying the Source
> to an Actor. All this seems pretty basic stuff, but for some reasons I
> cannot make work.
>
> I pushed a minimalist project  https://github.com/
> alexmasselot/play-akkastream-sse, but below is the controller code.
>
> *Story short:* the first stream works (tick), but the second one does not
> (actorFlow). More precisely, pushing messages through the Flow via
> Source.actorRef see them printed in the flow but not exposed to the http
> stream
>
> Both can be tested with
>
> curl  -H "Accept: text/event-stream" http://localhost:9000/ticks
> curl  -H "Accept: text/event-stream" http://localhost:9000/actor-flow
>
>
>
> Thanks a lot for the help,
>
> Alex
>
> @Singleton
> class StreamController @Inject()()(implicit exec: ExecutionContext,
> actorSystem: ActorSystem) extends Controller {
>   implicit val materializer = ActorMaterializer()
>
>
>   def tick = Action {
>     val tickSource = Source.tick(0 millis, 100 millis, "TICK")
>     Ok.chunked(tickSource via EventSource.flow).as(
> ContentTypes.EVENT_STREAM)
>   }
>
>   def actorFlow = Action {
>     val source = Source.actorRef[String](10, fail)
>       .map({ (x) =>
>         //the message go through this stage
>         println(s"through source '$x'")
>         x
>       })
>
>     val ref = Flow[String]
>       .to(Sink.ignore)
>       .runWith(
>         source
>       )
>
>     //send messages. One is now, oth is delayed
>     ref ! "PAF"
>     actorSystem.scheduler.scheduleOnce(1000 milliseconds, ref, "delayed
> PIF")
>
>     Ok.chunked(source via EventSource.flow).as(ContentTypes.EVENT_STREAM)
>   }
> }
>
>
>
>
> --
> >>>>>>>>>> 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 https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Cheers,
√

-- 
>>>>>>>>>>      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 https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to