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 3399F91B0 for ; Thu, 2 Aug 2012 16:18:54 +0000 (UTC) Received: (qmail 28479 invoked by uid 500); 2 Aug 2012 16:18:53 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 28419 invoked by uid 500); 2 Aug 2012 16:18:53 -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 28410 invoked by uid 99); 2 Aug 2012 16:18:53 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Aug 2012 16:18:53 +0000 X-ASF-Spam-Status: No, hits=1.3 required=5.0 tests=SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of SteveD@glam.com designates 209.80.10.125 as permitted sender) Received: from [209.80.10.125] (HELO mail.glam.com) (209.80.10.125) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Aug 2012 16:18:47 +0000 Received: from GLAMMX09.projecty.com ([192.168.8.228]) by ex2007-glam.projecty.com ([192.168.8.233]) with mapi; Thu, 2 Aug 2012 09:18:25 -0700 From: Steve Drach To: Willem jiang CC: "users@camel.apache.org" Date: Thu, 2 Aug 2012 09:18:23 -0700 Subject: Re: NPE in RouteContextProcessor Thread-Topic: NPE in RouteContextProcessor Thread-Index: Ac1wynFqjt3Q2lrFSsO+uOXYkWjVJA== Message-ID: In-Reply-To: <6A5FC7ED60D84B6CBDF0AF594AEB80B8@gmail.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Microsoft-MacOutlook/14.2.3.120616 acceptlanguage: en-US Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 It is a custom component built several years ago by a prior engineer in my = company, when the system was on Camel 1.4. I'm not sure if DefaultExchange= was thread safe back then or not, but it's certainly not thread safe today= . When I realized the issue I changed the routes from seda and sedax to di= rect since we do input spooling before sticking the message into the Camel = pipeline and I stopped getting NPE's and more importantly stopped losing me= ssages. This is a high volume email system and people, for years, have bee= n wondering why some mail doesn't get through ;-) So what is Camel's multi thread story/philosophy? Are there guide lines to= follow? From: Willem jiang > Date: Thursday, August 2, 2012 1:15 AM To: Steve Drach > Subject: Re: NPE in RouteContextProcessor It looks like you are using sedax component. I didn't see this component before, is it a custom component which you buil= d by yourself? -- Willem jiang On Wednesday, August 1, 2012 at 12:21 AM, Steve Drach wrote: On 7/31/12 2:40 AM, "Willem jiang" > wrote: What's your Camel route look like ? Here's the subset that shows the path taken, starting with "spool:core". The section marked with <=3D=3D=3D=3D is the last one I see in the trace. /* From Core */ from("spool:core:store") .process(new IllegalSMTPAddressFixer()) .process(new CopyFromAndToIntact()) .process(new AddressValidationFilter()) .choice() .when(header(DO_NOT_SEND).isNotNull()) .to("seda:drop") .otherwise() .to("sedax:delivery"); =A9 /* Shared */ from("sedax:delivery?threads=3D" + numOutgoingThreads) <=3D=3D=3D=3D=3D .process(new MessageTypeProcessor()) .process(logger) .to("smtp:out", "spool:*:delete"); from("seda:drop").to("direct:drop"); from("direct:drop") .process(new ConvertDeliveryToDeadDelivery()) .process(new LogDeadDelivery()) .to("spool:*:delete"); -- Willem Jiang On Tuesday, July 31, 2012 at 7:52 AM, Steve Drach wrote: I'm using Camel 2.4.10. I'm get a NPE in RouteContextProcessor at line 42: 29 public class RouteContextProcessor extends DelegateAsyncProcessor { ... 38 @Override 39 protected boolean processNext(final Exchange exchange, final AsyncCallback callback) { 40 // push the current route context 41 if (exchange.getUnitOfWork() !=3D null) { 42 exchange.getUnitOfWork().pushRouteContext(routeContext); 43 } I am able to demonstrate that even though the test in line 41 is true, getUnitOfWork() in null in line 43. I do this by instrumenting the code as follows: @Override protected boolean processNext(final Exchange exchange, final AsyncCallback callback) { // push the current route context try { if (exchange.getUnitOfWork() !=3D null) { exchange.getUnitOfWork().pushRouteContext(routeContext); } } catch (Exception e) { System.out.println("********************\n"+exchange); System.out.println(exchange.getUnitOfWork()); e.printStackTrace(); System.exit(1); } And I can clearly see the null value. This implies to me somebody else has a reference to the same exchange object and is changing it between lines 42 and line 43. This only happens occasionally (1 in 1000 times). My code has 10 threads, so I wouldn't be surprised if it was my problem, but I just can't see it. I am not doing anything with the UnitOfWork in an exchange. At most, I change the body of the Message and perhaps the headers. This is very difficult to debug because it happens so infrequently. Does anyone have a suggestion that could help me? -- View this message in context: http://camel.465427.n5.nabble.com/NPE-in-RouteContextProcessor-tp5716620. html Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).