Clustered Singleton using Wildfly?

后端 未结 1 1368
遇见更好的自我
遇见更好的自我 2020-12-06 14:18

I\'m trying to create a simple clustered Singleton on Wildfly 8.2. I\'ve configured 2 Wildfly instances, running in a standalone clustered configuration. My a

相关标签:
1条回答
  • 2020-12-06 14:56

    Singleton session beans provide a formal programming construct that guarantees a session bean will be instantiated once per application in a particular Java Virtual Machine (JVM).

    The JSR 318: Enterprise JavaBeans TM ,Version 3.1 says:

    A Singleton session bean is a session bean component that is instantiated once per application. In cases where the container is distributed over many virtual machines, each application will have one bean instance of the Singleton for each JVM

    Hence, in a clustered application, each cluster member will have its own instance of singleton session beans and data is not shared across JVM instances (in Wildfly implementation).

    In Wildfly if you need only one instance of singleton in a cluster scope you can use the SingletonService implementation. Using a SingletonService, the target service is installed on every node in the cluster but is only started on one node at any given time.

    See:

    • Implement an HA Singleton
    • cluster-ha-singleton: A SingletonService deployed in a JAR started by SingletonStartup and accessed by an EJB

    UPDATE:

    WildFly 10 adds the ability to deploy a given application as a "singleton deployment". This is a new implementation of a feature that existed in AS 6.0 and earlier. When deployed to a group of clustered servers, a singleton deployment will only deploy on a single node at any given time. If the node on which the deployment is active stops or fails, the deployment will automatically start on another node.

    See: WildFly 10 Final is now available!

    0 讨论(0)
提交回复
热议问题