• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Singletons with Clustering

 
James Adams
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Am I the only one trying to use singletons with clustering ? It seems to be something which should have been done many times before, but detailed information on how it works does not seem to be readily available. I have posted two messages to the JBoss/Clustering forum (see http://www.jboss.org/index.html?module=bb&op=viewtopic&t=52358 and http://www.jboss.org/index.html?module=bb&op=viewtopic&t=52330) but I have yet to receive any more information on how to get this to work. Does anyone have any experience with this ?

This is my first attempt to use JBoss Clustering, and aside from the singletons it appears to be simple to setup and run a JBoss cluster. The only article on how this works for singletons, http://www.onjava.com/pub/a/onjava/2003/08/20/jboss_clustering.html, which outlines creating a MBean to run as a singleton using the HASingletonController, isn't complete (no code for the MBean interface, no real direction on which cluster-service.xml to include the singleton and controller entries -- is it cluster-service.xml or cluster-examples-service.xml ?, do you package the SingletonMBean with other Mbeans in a SAR or in the EAR file ?, etc.), and I am having troubles not mentioned in the article.

The JBoss Clustering documentation I have shows that there are no clustering features available for Message-Drive EJBs -- so does this mean that running a singleton MDB, which runs fine in single JVM, as a singleton in the cluster is impossible ? If not then what else is required other than marking the MDB as <clustered> in the joss.xml ?

I am running JBoss 3.2.5. Any suggestions or information will be appreciated. Thanks in advance.


--James
 
Frederico Melo
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James,

At first you need to be completly sure about the needs to use a singleton. It should *NOT* be used on a multi-classloader enviroment since it's unique gaim (a single instance of a class on whole application) it's not garanteed on a multi-VM (multi-classloader) enviroment.
The only approach that can be used to emulate a singleton on a App. Server is exposing it on the JNDI context(wich can be done or not by JMX Mbeans). This way, your app has a unique point for acquiring a reference to a object(even across clustered app servers) in transparent way, and you can garantee that you factory exposed in JNDI context will only let one object copy exist.

best regards,

Fred
 
James Adams
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So is it really not possible to have true singletons in a multi-VM (clustered) environment ? It seems that this is in fact possible, even though I have yet to get it to work for my application. There is a JBOSS/server/all/deploy-hasingleton directory for deploying singleton MBeans, and the previously mentioned article explains (though not completely) that it can be done. As far as using the cluster-wide HANamingService, I am doing this (I think) by removing the



from the InitialContext properties, and this makes the Context use port 1100, which is the HANamingService (cluster-wide JNDI). Is this not the case, or are there other things I should do as well ?

Thanks in advacnce for any further suggestions, as I am right near stumped on this.


--James
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic