Search code examples
javacluster-computingcdi

@ApplicationScoped in a cluster


I don't have a clustered environment at present, but I was curious about @ApplicationScoped behaviour in a clustered environment. Is there going to be only one across the cluster or is still still one per JVM in the cluster?

I have read that @Singleton gets created per JVM in

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


Solution

  • @ApplicationScoped beans are not replicated per se.

    There may be some containers or servers replicating those beans, but it is not part of the CDI spec. By default, the beans are not shared across JVMs. CDI will create one unique proxy per cluster member / jvm.

    The part of Jakarta EE that is designed to handle this (by specification), is EJB.