Dan Osterrath [http://community.jboss.org/people/DanOsterrath] created the 
discussion

"Singleton in clustered JBoss AS 6 Final"

To view the discussion, visit: http://community.jboss.org/message/583084#583084

--------------------------------------------------------------
Hello to everyone,

I have a singleton session bean that handles some nightly database cleanup and 
import. This is done via @Singleton and @Schedule annotation. Unfortunately 
when deploying in a cluster this bean is executed on all nodes.

package session;
 
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Date;
 
import javax.ejb.Schedule;
import javax.ejb.Singleton;
 
import org.jboss.ejb3.annotation.Clustered;
 
@Singleton
@Clustered
public class MyScheduler {
    @Schedule(second = "*/20", minute = "*", hour = "*", persistent = false)
    public void printTime() {
        System.out.println(getHostName() + ": " + new Date());
    }
 
    private String getHostName() {
        try {
            InetAddress addr = InetAddress.getLocalHost();
            return addr.getHostName();
        } catch (UnknownHostException e) {
        }
        return "";
    }
}

This example prints the hostname and the current time on all nodes.

That behaviour seems to fit the EJB 3.1 requirements but is quite useless for 
me (and probably others). So how can I implement an high available singleton in 
a cluster? If there is no way how can I block the other nodes singleton 
instances so that only one gets executed?
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/583084#583084]

Start a new discussion in EJB3 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]

_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to