Archimedes Trajano
Archimedes Trajano

Reputation: 41450

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

Upvotes: 7

Views: 1231

Answers (2)

Hannes Schneidermayer
Hannes Schneidermayer

Reputation: 5777

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

Upvotes: 1

Keith
Keith

Reputation: 3151

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.

Upvotes: 1

Related Questions