7

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?

Community
  • 1
  • 1
Archimedes Trajano
  • 35,625
  • 19
  • 175
  • 265

2 Answers2

1

References to @ApplicationScoped are proxied, so they will be correctly resolved by the CDI container. That holds true no matter how many nodes are present within the application; the state and instance is shared across all client requests.

Keith
  • 3,079
  • 2
  • 17
  • 26
1

@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.

Hannes Schneidermayer
  • 4,729
  • 2
  • 28
  • 32