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

**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.
The actor-per-request 
<http://techblog.net-a-porter.com/2013/12/ask-tell-and-per-request-actors/> 
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
      }
    }


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




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