Migrate / create HA-Singleton in jboss 7

I use the deploy-hasingleton folder in jboss as 6, this allowed me to create a singleton bean that is used to manage requests for business information from cluster nodes. These methods are synchronized to control concurrency between nodes (the same data cannot be in different nodes).

Now, when I go to Jboss 7, and since this deploy-hasingleton folder has disappeared, I follow the official examples:

The problem is that these examples are too trivial, and I could not figure out where I can place the business logic methods. So I tried putting this logic in a SingletonService that implements: Service, MyInterface

And I changed the getValue method to the following:

@Override public MyInterface getValue() throws IllegalStateException, IllegalArgumentException { return this; } 

On the client side:

 @Override public List<Long> myMeth(Long arg1, int arg2) { LOGGER.log("loadGroups() is called()"); ServiceController<?> service = CurrentServiceContainer.getServiceContainer().getService( GroupDistributorService.SINGLETON_SERVICE_NAME); if (service != null) { return ((MyInterface ) service.getValue()).getMyMethod(arg1, arg2); } else { throw new IllegalStateException("Service '" + GroupDistributorService.SINGLETON_SERVICE_NAME + "' not found!"); } } 

I doubt this is the right approach. And secondly, it works in a node that contains a master singleton service. However, in other nodes, it blocks when a singleton service is called, and I get a timeout.

+8
java-ee singleton migration jboss
source share
1 answer

A few months ago I posted a blog post about using HASingleton in Jboss 7: http://www.kubrynski.com/2013/07/using-ha-singleton-in-jboss-7.html Hope this helps. Make sure you enable clustering mode:

 <subsystem xmlns="urn:jboss:domain:ee:1.0"> <global-modules> <module name="org.jboss.msc" slot="main"> <module name="org.jboss.as.clustering.singleton" slot="main"> </global-modules> </subsystem> 

and that you stick to the osgi system by adding the following configuration to your pom.xml (for jar / war plugin):

 <configuration> <archive> <manifestentries> <dependencies> org.jboss.msc,org.jboss.as.server, org.jboss.as.clustering.singleton </dependencies> </manifestentries> </archive> </configuration> 
+1
source share

All Articles