Need to implement serverside timer using Play Framework 2.1.1 and AKKA

天涯浪子 提交于 2019-12-10 11:57:36

问题


My question:

How can I implement a timer for an auction?

  • Timer needs to run on the server
  • Since there are going to be many timers I don't want to waste a lot of resources on the function that runs the timer.

I am using play framework 2.1.1 and AKKA.

Can I store the timer in the database? updating it on retrieval?


回答1:


I guess you can get inspiration from the Java Comet Clock sample coming with Play framework

https://github.com/playframework/Play20/tree/master/samples/java/comet-clock

It use Akka for scheduling and Comet to push data to clients. Maybe your can use a better push solution like websockets or server sent events (you can check the websocket chat sample for that)

And if you need to store the timer in a DB, you can do that in the Clock Actor (or equivalent).



来源:https://stackoverflow.com/questions/16968359/need-to-implement-serverside-timer-using-play-framework-2-1-1-and-akka

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!