Return-Path: X-Original-To: apmail-camel-users-archive@www.apache.org Delivered-To: apmail-camel-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2A964DCA6 for ; Mon, 24 Sep 2012 15:21:36 +0000 (UTC) Received: (qmail 50068 invoked by uid 500); 24 Sep 2012 15:21:35 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 50010 invoked by uid 500); 24 Sep 2012 15:21:35 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 50000 invoked by uid 99); 24 Sep 2012 15:21:35 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Sep 2012 15:21:35 +0000 X-ASF-Spam-Status: No, hits=0.6 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of claus.ibsen@gmail.com designates 209.85.217.173 as permitted sender) Received: from [209.85.217.173] (HELO mail-lb0-f173.google.com) (209.85.217.173) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Sep 2012 15:21:31 +0000 Received: by lbbgm13 with SMTP id gm13so8516816lbb.32 for ; Mon, 24 Sep 2012 08:21:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=5yy9r2ISOz+GOp/wHbySjHaI3VVjBbX9FCv44JCR1MU=; b=MDJv+TCn8bCQaAc82MaAGwqqsvcVgFiykZhWyieVCFAD/X1tAgP17S+y+9reM+czwc c+woO//tRSilCmPreHEdj0CpswqqQ8pQVPT5dPw740KAn2c19/ZiLp4GICOzzQceNbNh PD5s2MWbAAyUcLh3Ntl2+ZPPjrWKka6+M+2JETNtH+F5oqs7/F/J0Vm8EIzuxexzISAu In7UT+Gc3OQcIZoLP+UYh5B88Ru1ULfiDUbVtp7Y8TyK1gQXC85SXN2HwpIbz7e10FSR Bk+qxgs4OLI/wxZ9pQ36exk8ZU6YE4OIRQz/EIyKEp6DQ+xPnIZFMSRe1leBYcBd9oPk T/gQ== Received: by 10.152.105.206 with SMTP id go14mr10723942lab.37.1348500069504; Mon, 24 Sep 2012 08:21:09 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.7.230 with HTTP; Mon, 24 Sep 2012 08:20:49 -0700 (PDT) In-Reply-To: <1348497635707-5719861.post@n5.nabble.com> References: <1348480755030-5719841.post@n5.nabble.com> <1348485094079-5719848.post@n5.nabble.com> <1348492787912-5719857.post@n5.nabble.com> <1348497635707-5719861.post@n5.nabble.com> From: Claus Ibsen Date: Mon, 24 Sep 2012 17:20:49 +0200 Message-ID: Subject: Re: Using a custom based load balancer. To: users@camel.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Hi In your hashmap, the session id should be the key. And the chosen processor should be the value. eg the type should be Map map =3D new ... On Mon, Sep 24, 2012 at 4:40 PM, balkishore w= rote: > 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 =3D new HashMap(); > > public void process(Exchange exchange) throws Exception { > Processor target =3D chooseProcessor(exchange); > XPathBuilder sessionID =3D > XPathBuilder.xpath("substring(string(/*[local-name()=3D'Envelope']/*[loca= l-name()=3D'Header']/*[local-name()=3D'ReplyTo']/*[local-name()=3D'Referenc= eParameters']/*[local-name()=3D'ServiceGroupId']/text()), > 10)", String.class); > String session =3D sessionID.evaluate(exchange, String.class); > > hm.put(getProcessors(),session); > target.process(exchange); > } > > protected Processor chooseProcessor (Exchange exchange) throws Exception > { > Namespaces env =3D 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 =3D exchange.getIn().getHeader("test", > env.xpath("substring(string(/soapenv:Envelope/soapenv:Header/wsa:ReplyTo/= wsa:ReferenceParameters/axis2:Serv=E2=80=8C > 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 don= e. > I have been struggling on this project for a while now. > > > > -- > View this message in context: http://camel.465427.n5.nabble.com/Using-a-c= ustom-based-load-balancer-tp5719841p5719861.html > Sent from the Camel - Users mailing list archive at Nabble.com. --=20 Claus Ibsen ----------------- Red Hat, Inc. FuseSource is now part of Red Hat Email: cibsen@redhat.com Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen