I've been using deploy-hasingleton folder in jboss as 6, this allowed me to create a singleton bean that is used to control business information requests from the cluster nodes. These methods are synchronized in order to control the concurrency between nodes (the same data cannot be in different nodes).
Now that I'm migrating to the Jboss 7, and since that deploy-hasingleton folder disappeared, I've been following the official examples:
The problem is that theses examples are too trivial, and I couldn't understand where I can place the business logic methods. So I tried to place that logic in the SingletonService, which implements: Service, MyInterface
And I've modified 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 that this is the correct approach. And second, this appears to work in the node that contains the master singleton service. However in other nodes, it locks when calling the singleton service, and I get a timeout.