Is there a way to exchange objects between multiple tomcat in a load balanced cluster?

I have two tomcat instances running on a balancing cluster. I also have an application that works in these two instances, and I have two doubts:

  • When an object changes its state in an instance, does it change on another, that is, preserving the same state (of this particular object) in both instances?

  • If the answer is no, then how can I share the preservation of the same state of an object in both instances without using a database?

+4
source share
1 answer

, , , , Hazelcast. , IAtomicReference, , , .

node Hazelcast , :

HazelcastInstance instance = Hazelcast.newHazelcastInstance();

, config xml , . , , - :

IAtomicReference<Foo> ref = instance.getAtomicReference("terefere");
if(ref.isNull()){
    ref.set(new Foo());
}

, , :

ref.apply(foo -> foo.setBar(true));
+3

All Articles