Hi claus,

Thanks a lot for replying.

I implemented the idea directed by you(I really appreciate that )
But due to some reason my requests are not being forwarded, camel is
continuously retrying.

Here is my code for custom load balancer:

public class MyCustomLoadBalancer extends SimpleLoadBalancerSupport 

{
private final HashMap hm = new HashMap(); 
        
public void process(Exchange exchange) throws Exception {
Processor target = chooseProcessor(exchange);
XPathBuilder sessionID =
XPathBuilder.xpath("substring(string(/*[local-name()='Envelope']/*[local-name()='Header']/*[local-name()='ReplyTo']/*[local-name()='ReferenceParameters']/*[local-name()='ServiceGroupId']/text()),
10)", String.class);
String session = sessionID.evaluate(exchange, String.class);

hm.put(getProcessors(),session);
target.process(exchange);
}

protected Processor chooseProcessor (Exchange exchange) throws Exception   
{
        Namespaces env = new Namespaces("soapenv",
"http://schemas.xmlsoap.org/soap/envelope/";);
        env.add("wsa", "http://www.w3.org/2005/08/addressing";);
        env.add("axis2", "http://ws.apache.org/namespaces/axis2";);

        Object expression = exchange.getIn().getHeader("test",
env.xpath("substring(string(/soapenv:Envelope/soapenv:Header/wsa:ReplyTo/wsa:ReferenceParameters/axis2:Serv‌
iceGroupId/text()), 10)", String.class));
        
        if (expression.equals(hm.get(getProcessors())))
        {
                return getProcessors().get(0);
                } else {
                return getProcessors().get(1);
                }
}
}

And my main is something like this :

from(uri).loadBalance(new MyCustomLoadBalancer()).to(BE1,BE2);

where URI, BE1 and BE2 are the URLs.

Am I doing something wrong in my custom load balancer method?
I would be glad if you could help me or point out the mistake, I have done.
I have been struggling on this project for a while now.



--
View this message in context: 
http://camel.465427.n5.nabble.com/Using-a-custom-based-load-balancer-tp5719841p5719861.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to