Of course it helps, if I understand, Im' trying to something that cannot be done..
But let's say I have the following problem : An app allow customisation via commands sent to a fixed URL via HTTP POST. But I don't have a fixed url or cannot allow any incoming connexion. That's why I would ike to create this *relay* that can be deployed on any PaaS. So that in one side it receive commands and in the other side it publish them so that the bot can receive, process and reply to them. In other words : I would like to create something that is started for each new HTTP POST request, send it to a "channel" , wait for the response and return the response to the HTTP reuqest. Each commands has one unique id that can be used to route a response to the original HTTP request. On Wednesday, 1 June 2016 09:27:03 UTC+2, √ wrote: > > Hi! :) > > On May 31, 2016 1:09 PM, "User 48" <[email protected] <javascript:>> > wrote: > > > > I there, > > > > I would like to create a service who acts as a relay between plain Http > POST and WebSocket. The idea is to have this service who forward any POST > requests body to a Websocket channel and use the Websocket response as Http > response or send it to another server if the Websocket response arrive > after a given delay. > > > > > > [Bot] [Relay] [Client] > > | | . > > |--ws:connect-->| . > > | |<--HTTP/POST (Cmd)--| > > |<--- (Cmd) ----| | > > |---- (Resp) -->| | > > [ if duration<delay] > > | |------ (Resp) ----->| > > [ else ] > > | |--HTTP/PUT (Resp)-->| > > [ /if ] > > > > Command handling sequence diagram > > > > > > It seems feasible but I would like to use Akka and being a beginner I > have some questions : > > > > **1/** I can't find anything explaining how to create a Socket where I > can write at any time. > > This "unfortunately" doesn't exist. (Not as in Akka Http, but as in > Reality) > > Relying on such an assumption will lead to subtly (or not so subtly) > broken systems. > > What are the requirements, implementation aside? > > > The Bot must be "always" connected so that the webscoket channel will be > always opened. I have to write on it only when receiving an Http POST > request. But in the samples it is a request-response flow. > > See above. > > > > > **2/** Each incoming Cmd must have his own actor to be linked to the > orginal Client and decide if the response can be sent to the Http flow or > must be send via a new Http/PUT if the delay is expired. > > How do you identify the "original Client"? > > > The actor-per-request pattern seems to be the perfect candidate. But I > would like to create a Relay actor for each request and let this one handle > the request and send the response (`RequestContext.complete`) but when > doing that I cannot create the Route because I don't have any return type. > > > > path("test") { > > (post & entity(as[Command])) { (ctx, cmd) => > > serve(ctx, cmd) // Produce a Relay actor for `ctx` and `? cmd` > to it > > } > > } > > Hmmm, does this section of the documentation help? > > http://doc.akka.io/docs/akka/2.4.6/scala/http/routing-dsl/index.html > > > > > > > The NET-A-PORTER sample is using Spray which seems to allow direct use > of actors as route element but I cannot find the equivalent for Akka-http. > > > > > > Can someone help me or point me to the documentation part ? > > > > Thanks a lot > > I hope I was of *some* help, > let the group know if you made progress! > > Cheers, > √ > > > > > > > > > > > (this question was originally posted on StackOverflow : > http://stackoverflow.com/questions/37524001/akka-websocket-emit-to-stream-and-produce-one-actor-per-request > ) > > > > -- > > >>>>>>>>>> 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] <javascript:>. > > To post to this group, send email to [email protected] > <javascript:>. > > Visit this group at https://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 https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
