You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by bruce76 <bh...@apress.com> on 2006/07/24 22:39:10 UTC

Does the NMR perform any load balancing?

Hi,

I registered two services with the same endpoint. I verified this by
subsequently calling ComponentContext.getEndpointsForService() which
returned an array of 2 objects. When I try to send messages to the endpoint,
only the 2nd service get the message, and the 1st service gets nothing.

Any ideas why it works like that?

Thanks,

Bruce
-- 
View this message in context: http://www.nabble.com/Does-the-NMR-perform-any-load-balancing--tf1994728.html#a5474921
Sent from the ServiceMix - User forum at Nabble.com.


Re: Does the NMR perform any load balancing?

Posted by Guillaume Nodet <gn...@gmail.com>.
When using implicit endpoint selection, which is the case, because the jbi
endpoint
is not explicitely chosen (only by its service name), the NMR will choose
one endpoint
and send the exchange to it.
The default policy is to choose the first one (I think the order in which
they are declared is not
relevant here, because there is an unordered map somewhere).
This policy is pluggable and you can easily implement any policy you want.
See org.apache.servicemix.nmr.DefaultBroker#setDefaultServiceChooser.
You can also configure such a policy on the activationSpec for the component
that
send the exchange.
See org.apache.servicemix.jbi.container.ActivationSpec#setServiceChooser

Cheers,
Guillaume Nodet


On 7/25/06, bruce76 <bh...@apress.com> wrote:
>
>
> Ok, let me clarify (and please excuse me if I use the wrong terminology).
>
> 1. I have one component that sends a normailzed message to a service:
>
> messageExchange.setService(new QName("http://www.abc.com", "receiver"));
>
> 2. I have two components that activate that service (however, they have
> different endpoints):
>
> // code in the 1st component
> endpoint = context.activateEndpoint(new QName("http://www.abc.com",
> "receiver"), "receiver1");
>
> // code in the 2nd component
> endpoint = context.activateEndpoint(new QName("http://www.abc.com",
> "receiver"), "receiver2");
>
> 3. All three components are listed in my servicemix.xml file, and all
> three
> are instantiated and initialized. Now, the problem is that the 2nd
> component
> gets all the requests from the sender. If I comment the 2nd service out
> from
> the servicemix.xml then the 1st component gets all the requests.
>
> I expected that the NMR would load balance and send requests to both
> services. It's unfortunate to see that the LAST service that activates
> under
> the same service name get all the requests.
>
> Thanks,
>
> Bruce
>
> --
> View this message in context:
> http://www.nabble.com/Does-the-NMR-perform-any-load-balancing--tf1994728.html#a5485323
> Sent from the ServiceMix - User forum at Nabble.com.
>
>

Re: Does the NMR perform any load balancing?

Posted by bruce76 <bh...@apress.com>.
Ok, let me clarify (and please excuse me if I use the wrong terminology).

1. I have one component that sends a normailzed message to a service:

messageExchange.setService(new QName("http://www.abc.com", "receiver"));

2. I have two components that activate that service (however, they have
different endpoints):

// code in the 1st component
endpoint = context.activateEndpoint(new QName("http://www.abc.com",
"receiver"), "receiver1");

// code in the 2nd component
endpoint = context.activateEndpoint(new QName("http://www.abc.com",
"receiver"), "receiver2");

3. All three components are listed in my servicemix.xml file, and all three
are instantiated and initialized. Now, the problem is that the 2nd component
gets all the requests from the sender. If I comment the 2nd service out from
the servicemix.xml then the 1st component gets all the requests.

I expected that the NMR would load balance and send requests to both
services. It's unfortunate to see that the LAST service that activates under
the same service name get all the requests.

Thanks,

Bruce

-- 
View this message in context: http://www.nabble.com/Does-the-NMR-perform-any-load-balancing--tf1994728.html#a5485323
Sent from the ServiceMix - User forum at Nabble.com.


Re: Does the NMR perform any load balancing?

Posted by Guillaume Nodet <gn...@gmail.com>.
A JBI endpoint is identified by the service qname + the endpoint name.
So if you have 2 objects in your array, you have 2 different jbi endpoints,
not one.
Also note that load balancing can only occur when clustering servicemix with
a jms or jca flow (in a given jbi container, jbi endpoints are unique and
you can not
the same endpoint twice).

Cheers,
Guillaume Nodet

On 7/24/06, bruce76 <bh...@apress.com> wrote:
>
>
> Hi,
>
> I registered two services with the same endpoint. I verified this by
> subsequently calling ComponentContext.getEndpointsForService() which
> returned an array of 2 objects. When I try to send messages to the
> endpoint,
> only the 2nd service get the message, and the 1st service gets nothing.
>
> Any ideas why it works like that?
>
> Thanks,
>
> Bruce
> --
> View this message in context:
> http://www.nabble.com/Does-the-NMR-perform-any-load-balancing--tf1994728.html#a5474921
> Sent from the ServiceMix - User forum at Nabble.com.
>
>