JBoss Community

EJB3 Injection

created by André Simões in EJB3 - View the full discussion

Hi.

 

Imagine the following scenario:

 

One JBoss cluster with web apps

Other JBoss cluster with Ejb, jms, etc..

The clusters are isolated by a DMZ.

 

From the web app cluster, I need to inject some EJB's from the other cluster.

The only way (that I realize) to do it is with some code like this:

 

static public TestFacade assfac(){
 
    if( Facade._assfac ==null ) {
        
        try {
            Context ctx = new InitialContext(getProperties());
            Facade._assfac =  (TestFacade) ctx.lookup("TestFacade/remote");
        } catch (Exception e) {
            Facade._assfac = null;
            log.error(e.getMessage());
        }        
    }        
    return Facade._assfac;
}    
 
//pass cluster urls for injection
//Ex: facadeurls="192.168.0.1,192.168.0.2"
private static Properties getProperties() {
    String facadeurls = System.getProperty("FacadeUrls", ""); 
    Properties p = System.getProperties();
 
    if (facadeurls.length()> 1)    {//Got property on path
        p.put(Context.PROVIDER_URL, facadeurls);    
    }
    
    return p;
}

 

This approach works, but do not work well!

 

1º It tends to always inject from the first ip found on properties.

 

2º If jboss node from first ip is offline, it injects from the next ip, but if jboss fails after injection, we have to inject again or we receive a connection refused.

 

There are some way to have some kind of load balancing/failure detection on ejb injection?

 

Do someone sugests another way to solve this problem?

 

Thanks.

Reply to this message by going to Community

Start a new discussion in EJB3 at Community