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 F08409EEE for ; Sat, 25 Aug 2012 21:13:28 +0000 (UTC) Received: (qmail 60458 invoked by uid 500); 25 Aug 2012 21:13:28 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 60377 invoked by uid 500); 25 Aug 2012 21:13:28 -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 60367 invoked by uid 99); 25 Aug 2012 21:13:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 25 Aug 2012 21:13:27 +0000 X-ASF-Spam-Status: No, hits=2.8 required=5.0 tests=HTML_IMAGE_ONLY_32,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of christian.mueller@gmail.com designates 209.85.216.45 as permitted sender) Received: from [209.85.216.45] (HELO mail-qa0-f45.google.com) (209.85.216.45) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 25 Aug 2012 21:13:21 +0000 Received: by qadc10 with SMTP id c10so1259427qad.11 for ; Sat, 25 Aug 2012 14:13:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=kWKf/RtJVJp/Bx82OfFXgH20T/qiqieOAp1O0bCx/ms=; b=JEXI2frp3ORamduDdGCMJCzLu6a0gTkgxQCsJrHQjtr8fKtvIGrwIhlWI6zk3RuvXQ lz3cm/1Dmfwpd1Xsw4TIoRLoXt4bRJ91Aky7BIM51qVhp32kynB0lHKMj5eSkpStH923 9re9hAz1cl4R8+j/N9mc6yOaQZGLk50JG8K+QWrF+zuaD78isHoFRh5A/VDWlplDDucZ mahmJH2zF01XwcX5gVnsCD1Xq9z3GBr6r2f8YIb23nKh8GTunsL8Bv20qP5/E9c4vb0Q /d/kN83KYv4FoNfcp0qgKfwLe1fM5Xpo3CkUNRK3v4PGP8S/a3m+BsTgd2ji96Cx8jkk WN4A== MIME-Version: 1.0 Received: by 10.224.33.205 with SMTP id i13mr15882732qad.18.1345929180352; Sat, 25 Aug 2012 14:13:00 -0700 (PDT) Received: by 10.49.116.200 with HTTP; Sat, 25 Aug 2012 14:13:00 -0700 (PDT) In-Reply-To: <1345688900844-5717906.post@n5.nabble.com> References: <1345658393855-5717888.post@n5.nabble.com> <1345666780343-5717898.post@n5.nabble.com> <1345688900844-5717906.post@n5.nabble.com> Date: Sat, 25 Aug 2012 23:13:00 +0200 Message-ID: Subject: Re: concurrent users with camel routes From: =?ISO-8859-1?Q?Christian_M=FCller?= To: users@camel.apache.org Content-Type: multipart/alternative; boundary=20cf3074d58cb0115704c81d8e25 --20cf3074d58cb0115704c81d8e25 Content-Type: text/plain; charset=ISO-8859-1 Hi Javakurious! Please find my responses inline in your mail. Best, Christian On Thu, Aug 23, 2012 at 4:28 AM, javakurious wrote: > Thanks Christian for the response. > > If I understand your response correctly, a single instance of processor > will > be shared between thread safe. Isn't that inefficient? > No. It is efficient. > > In my specific example, I have a processor RequestProcessor which extracts > the body of the exchange, parses the body into an XML document and examines > element values using XPATH , and does some additional processing. > > RequestProcessor(){ > > private DocumentBuilder db; > > public RequestProcessor(){ > db=DobcumentBuilderFactory.newInstance(); // initialize > DocumentBuilder > } > > public void process(Exchange exchange){ > String body = exchange.getIn().getBody(String.class) > Document doc = db.parse(body); > //process the doc. > } > > } > In the above example, if each HTTP thread is sharing the same > RequestProcessor instance, won't it have performance impact if I have to > synchronize "db.parse(body)" section or a more complex time consuming > section ? > Yes it will be your bottleneck. I assume the DocumentBuilder is not thread safe? If it's thread safe, you don't have to synchronize the access... If it's not, why you don't create a new DocumentBuilder for each method invocation? To expensive? Than pool a few DocumentBuilder instances (we do similar things with the JAXB Marshaler/Unmarshaler, if I remember right). > > Is there a way to create a pool of these processors so that each HTTP > thread > can use a dedicated process for the duration of a request ? > Why pooling the processors and not the DocumentBuilder's? Wouldn't that be more efficient? > > Thanks > > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/concurrent-users-with-camel-routes-tp5717888p5717906.html > Sent from the Camel - Users mailing list archive at Nabble.com. > -- --20cf3074d58cb0115704c81d8e25--