开发者

EJB singleton as shared memory?

I wish to ask if you would recommend EJB3.1 singleton beans as storage for application memory shared data. Imagine some simple application that needs to hold data in memory (r开发者_JAVA百科ather than in a database) - e.g. some instant messaging server got data who is and who isn't online (user status).

Would you recommend usage of EJB3.1 singletons or do you prefer some typical caching mechanisms like Coherence and so on? I can imagine a cluster with multiple JVMs, then comes to my mind to use JMS to tell other singletons that application memory changed.


EJB singletons are very convenient for providing access to small amounts of application scoped data, but I wouldn't recommend using only them for managing very large amounts of data shared in a cluster.

Typical caching solutions like Coherence or Infinispan have a lot of features like eviction policies, cluster replication topologies, spill over to disk, etc, that you'll really appreciate in those situation.

Singletons can be conveniently used to give your other beans access to global resources like an Infinispan cache though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜