Its just an artificial, simple way to model a slow process for the benefit of this example.
On Saturday, December 12, 2015 at 3:26:05 PM UTC-5, [email protected] wrote: > > Why you are using Thread.sleep? > > On Saturday, December 12, 2015 at 5:33:16 PM UTC-2, Bill Donn wrote: >> >> I can't seem to get back pressure working on a web socket server. >> >> I'm using the example off the akka docs. >> >> >> >> >> >> >> *val requestHandler: HttpRequest ⇒ HttpResponse = { case req @ >> HttpRequest(GET, Uri.Path("/greeter"), _, _, _) ⇒ >> println(req.headers.mkString) req.header[UpgradeToWebsocket] match >> { case Some(upgrade) ⇒ upgrade.handleMessages(* >> >> >> >> >> * Flow[Message].mapAsyncUnordered(1)(takeItSlow) ) case >> None ⇒ HttpResponse(400, entity = "Not a valid websocket >> request!") } case _: HttpRequest ⇒ HttpResponse(400, entity = >> "Unknown resource!") }* >> >> My flow handler is a simple and highly contrived future designed to >> consume time: >> >> >> >> >> *def takeItSlow(m : Message) : Future[Message] = { case >> message => Future(Thread.sleep(1000); TextMessage(message)) }* >> >> I can call this just fine, and am able to create a web socket and send >> several thousand messages, and get back a smaller number (most - I guess - >> are sleeping) , but then it crashes from out of memory. Clearly there is >> no back pressure. What am I doing wrong? >> >> >> >> -- >>>>>>>>>> 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.
