How singleton is javax.ejb.Singleton in a clustered environment?

后端 未结 3 1255
说谎
说谎 2020-12-31 19:42

I need to maintain a simple counter that is unique within the application, for all users and all nodes in a clustered environment. I thought about using the singleton sessio

3条回答
  •  [愿得一人]
    2020-12-31 20:04

    Would every node of the cluster have it's own instance or not?

    Yes, each cluster node will have a different Singleton instance. Therefore, @Singleton annotation is not the solution for your problem.

    Take in mind that Java EE specification doesn't define any kind of cluster behavior. You need to search for specific vendor solution to achieve this kind of requirement. Just as an example see this link.

提交回复
热议问题