Hi Javakurious! Please find my responses inline in your mail.
Best, Christian On Thu, Aug 23, 2012 at 4:28 AM, javakurious <[email protected]> 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. > --
