I have a WebSocket server in a Play app, and I want to move it to an akka-http service. I'm currently using ActorFlow.actorRef
, which is a part of Play that doesn't exist in Akka.
When the WebSocket is accepted, I subscribe to a RabbitMQ queue, and forward each message to the WebSocket. When I receive a message from the WebSocket, I handle some locally and forward others on to a RabbitMQ exchange.
How would I do the same using akka-http? I can create a sink using Sink.actorRef
and handle inbound messages there, but what about the source?
I can create a source with Source.actorRef
, but how do I get access to the actor to send messages to when it's materialized? Is there a different kind of source I should use to send messages to from the foreach
of my RabbitMQ subscription?
Once I have those, it looks like I can return the required flow using Flow.fromSinkAndSource
.
ActorFlow.actorRef
). It closes the connection as soon as it's opened, though. gist.github.com/danellis/643e858d830dbea58bd84e265fb64110 – Isvara