JBoss Community

Re: Clustering an application that uses Spring singletons

created by Alessandro Novarini in Beginner's Corner - View the full discussion

Just to tell you how the developers decided to solve this "issue".

 

Basically, the injected singleton became a service, so singleton on every node, with a dependency to the HASingletonDeployer, just like the following:

 

@Service(objectName="jboss.myApp:service=myService")

@Depends("jboss.ha:service=HASingletonDeployer,type=Barrier")

 

 

In this way the bean will be deployed just once for all the cluster instances.

From now on, for referencing your bean, you can use the Depends annotation on the field:

 

@Depends("jboss.myApp:service=myService")

private MyService myService;

 

 

In our scenario, since the data are loaded once in a day and put into the cache, we're fine even if we experience same gap before the service starts again on another node.

 

Thanks

Ale

Reply to this message by going to Community

Start a new discussion in Beginner's Corner at Community