Your load balancer should be stateful, so create a map as a variable
at the class level.
Then the map can be shared between the methods.

public class ... {
 // stateful map to keep track of session id -> processors
private final Map map = new HashMap();

 // methods here
}

On Mon, Sep 24, 2012 at 3:19 PM, balkishore <balkishore.pan...@gmail.com> wrote:
> Hi claus,
> I tried implementing your logic and it is as follow:
>
> public class MyCustomLoadBalancer extends SimpleLoadBalancerSupport
>
> {
>
> 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);
> HashMap hm = new HashMap();
> 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()
>
> }
> }
>
> Now the problem is how can I call the hashmap object in my choose procesor
> method? I cannot extend my choose processor method.
>
> I am struck in the if part of the choose processor.
>
> Could you please assist me in this?
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Using-a-custom-based-load-balancer-tp5719841p5719857.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cib...@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to