[jboss-user] [EJB3] - EJB3 Injection

André Simões do-not-reply at jboss.com
Wed Nov 23 09:20:08 EST 2011


André Simões [http://community.jboss.org/people/asimoes] created the discussion

"EJB3 Injection"

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

--------------------------------------------------------------
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
[http://community.jboss.org/message/637948#637948]

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20111123/8a6e75e1/attachment.html 


More information about the jboss-user mailing list