You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by VikasRathee <vi...@gmail.com> on 2017/09/15 12:05:02 UTC

want to use load balancer while doing lookup , so that request can go to multiple instances for EJB

Hi

In my application , from  web module, I want to access EJBModule deployed on
multiple instances.
So I want to add something like load balancer while doing lookup. What i
need to do. 

            /  Properties properties = new Properties();
            properties.put(Context.INITIAL_CONTEXT_FACTORY, 
          "org.apache.openejb.client.RemoteInitialContextFactory");
            properties.put(Context.PROVIDER_URL,
"http://127.0.0.1:8081/tomee/ejb");
            InitialContext ic=new InitialContext(properties);/

This code is working fine with one PROVIDER_URL, but if i'm giving other URL
also with comma separated, i'm getting naming exception.
Is there anything like i can implement a EJB broker kind of thing which can
manage requests to multiple app servers.





--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html

Re: want to use load balancer while doing lookup , so that request can go to multiple instances for EJB

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

You can use failover:url1,url2 or failover:roundrobin:url1,url2 for
instance to pass multiple instance. If you want a custom strategy just do N
lookups and implement a proxy with the custom strategy - like circuit
breaker for instance.

Le 16 sept. 2017 04:35, "VikasRathee" <vi...@gmail.com> a écrit :

> Hi
>
> In my application , from  web module, I want to access EJBModule deployed
> on
> multiple instances.
> So I want to add something like load balancer while doing lookup. What i
> need to do.
>
>             /  Properties properties = new Properties();
>             properties.put(Context.INITIAL_CONTEXT_FACTORY,
>           "org.apache.openejb.client.RemoteInitialContextFactory");
>             properties.put(Context.PROVIDER_URL,
> "http://127.0.0.1:8081/tomee/ejb");
>             InitialContext ic=new InitialContext(properties);/
>
> This code is working fine with one PROVIDER_URL, but if i'm giving other
> URL
> also with comma separated, i'm getting naming exception.
> Is there anything like i can implement a EJB broker kind of thing which can
> manage requests to multiple app servers.
>
>
>
>
>
> --
> Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-
> f982480.html
>

Re: want to use load balancer while doing lookup , so that request can go to multiple instances for EJB

Posted by David Blevins <da...@gmail.com>.
Hi Vikas,

Definitely check out this section of the documentation:

 - http://tomee.apache.org/ejb-failover.html

The "failover:" URL prefix Romain mentions is one of a handful of features you can use.  The "failover:" strategy is great if you don't need dynamic loadbalancing and you are ok to fix the list statically on the client side.

There are also two options for having just one or two fixed and the rest discovered dynamically allowing for you to add/remove servers at runtime.  It's effectively the same as the "failover:" approach, but now the client will get an always up-to-date list dynamically.

If you happen to be in AWS this would be the one you need:

 - http://tomee.apache.org/multipoint-discovery.html
 - http://tomee.apache.org/multipoint-recommendations.html


-- 
David Blevins
http://twitter.com/dblevins
http://www.tomitribe.com

> On Sep 15, 2017, at 5:05 AM, VikasRathee <vi...@gmail.com> wrote:
> 
> Hi
> 
> In my application , from  web module, I want to access EJBModule deployed on
> multiple instances.
> So I want to add something like load balancer while doing lookup. What i
> need to do. 
> 
>            /  Properties properties = new Properties();
>            properties.put(Context.INITIAL_CONTEXT_FACTORY, 
>          "org.apache.openejb.client.RemoteInitialContextFactory");
>            properties.put(Context.PROVIDER_URL,
> "http://127.0.0.1:8081/tomee/ejb");
>            InitialContext ic=new InitialContext(properties);/
> 
> This code is working fine with one PROVIDER_URL, but if i'm giving other URL
> also with comma separated, i'm getting naming exception.
> Is there anything like i can implement a EJB broker kind of thing which can
> manage requests to multiple app servers.
> 
> 
> 
> 
> 
> --
> Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html