需要使用Play Framework 2.1.1和AKKA实现服务器端计时器 [英] Need to implement serverside timer using Play Framework 2.1.1 and AKKA
问题描述
我的问题:
如何实现拍卖计时器?
- 计时器需要在服务器上运行
- 由于会有很多计时器,所以我不想在运行计时器的函数上浪费很多资源.
我正在使用Play框架2.1.1和AKKA.
I am using play framework 2.1.1 and AKKA.
我可以将计时器存储在数据库中吗?在检索时对其进行更新?
Can I store the timer in the database? updating it on retrieval?
推荐答案
我想您可以从Play框架附带的Java Comet Clock示例中获得启发
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
它使用Akka进行调度,并使用Comet将数据推送到客户端.也许您可以使用更好的推送解决方案,例如websockets或服务器发送的事件(您可以查看websocket聊天示例)
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)
如果需要将计时器存储在数据库中,则可以在Clock Actor(或等效功能)中进行.
And if you need to store the timer in a DB, you can do that in the Clock Actor (or equivalent).
这篇关于需要使用Play Framework 2.1.1和AKKA实现服务器端计时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!