每个集群实现的 Payara 单例

Payara singleton per cluster implementation

EJB 是否定义了集群?我发现无状态或有状态 bean 的集群是特定于 ex 的平台。 Jboss 有 @Clustered 注释但在 Payara 中?我在多台机器上有相同的应用程序,我想对整个集群执行领导者选举或一种单一调用

Payara Server 和 Payara Micro 的最新版本(自 182 起)能够使用集群单例,如本博客所述post:https://blog.payara.fish/introduction-to-clustered-singleton

您只需要使用 fish.payara.cluster.Clustered(并确保 bean 是可序列化的),如博客所述:

import fish.payara.cluster.Clustered;
import javax.ejb.Singleton;
import javax.enterprise.context.ApplicationScoped;

@Clustered @Singleton
public class MyClusteredSingletonEJB implements Serializable { /* ... */ }

@Clustered @ApplicationScoped
public class MyClusteredSingletonCDI implements Serializable { /* ... */ }