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 EE667FB99 for ; Thu, 28 Mar 2013 11:26:16 +0000 (UTC) Received: (qmail 96008 invoked by uid 500); 28 Mar 2013 11:26:16 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 95347 invoked by uid 500); 28 Mar 2013 11:26:14 -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 95307 invoked by uid 99); 28 Mar 2013 11:26:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Mar 2013 11:26:12 +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.219.53 as permitted sender) Received: from [209.85.219.53] (HELO mail-oa0-f53.google.com) (209.85.219.53) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Mar 2013 11:26:09 +0000 Received: by mail-oa0-f53.google.com with SMTP id m17so8511315oag.12 for ; Thu, 28 Mar 2013 04:25:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:content-type:content-transfer-encoding; bh=KrC7cx+DvQVWdnqlb/NkQKLdED4u68kyNjQy1XQQvxA=; b=qPpt+ssyvLbfcW0BSnedoxh7rRUnB2OcYAIpzDb+3IgUpGsZDwbPlFFVZYYkAqQ52U /B6S63LR2hBF1qNSrzZoNpX08n6hQPQkkqP67ZKN8ID6zzUCkd4vz1ZA1dXLBW+2IQ1T tfIk1N7xxpcjDu8MZd05PY7C66IsBlLPAbRDySuJNGphxJM+J/RuyrMD9dCQW08GqASs mVbCQOwaM0wPEu54lNxQH27iHeNYCZz2Lln0U4PUebLtoZwkTbOCJ3g3XbO1BbzyLBvr n+nRMaZH3nFjzuV7CmIviADCQcRRIT8cmzK9/rgizbvqHb7YN+oHUlDq6bAGkTdaKBLr bcJQ== X-Received: by 10.182.136.72 with SMTP id py8mr5265136obb.0.1364469948594; Thu, 28 Mar 2013 04:25:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.60.62.102 with HTTP; Thu, 28 Mar 2013 04:25:28 -0700 (PDT) In-Reply-To: References: <1364303596339-5729849.post@n5.nabble.com> From: Claus Ibsen Date: Thu, 28 Mar 2013 12:25:28 +0100 Message-ID: Subject: Re: Clearing ThreadLocal when exchange completes To: users@camel.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On Thu, Mar 28, 2013 at 9:36 AM, Raul Kripalani wrote: > With this technique, developers have to remember to add the custom > processor at the start of each route. (Unless it's set from an > interceptor...). > > Since the user explicitly asked for a non intrusive technique, > EventNotifier is the only method that fulfills that requirement. Set once > per Camel context and forget about it. > > And it's higher level, not fiddling with internal APIs. > That would only work if its the same thread that calls the listener at exchange created and exchange done events. As he need to use that same thread for clearing his thread locals. > Just my 2 cents. > > Regards, > Ra=FAl. > On 28 Mar 2013 06:11, "Claus Ibsen" wrote: > >> On Wed, Mar 27, 2013 at 10:02 PM, Christian M=FCller >> wrote: >> > Isn't it called in a separate thread, isn't it? >> > >> >> Ah yeah, then use this as base class >> >> http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/came= l/support/SynchronizationAdapter.html >> >> And return false from the allowHandover method >> Then its done on the same thread. >> >> >> > Sent from a mobile device >> > Am 27.03.2013 08:14 schrieb "Claus Ibsen" : >> > >> >> You can use this method on the Exchange >> >> >> >> >> >> >> http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/came= l/Exchange.html#addOnCompletion(org.apache.camel.spi.Synchronization) >> >> >> >> >> >> On Tue, Mar 26, 2013 at 2:13 PM, davelund >> wrote: >> >> > We are currently using ThreadLocal to store some information that g= ets >> >> > included in a log4j converter (and is used in other projects that d= ont >> >> have >> >> > camel in). Is there a callback I can use that for all routes in my >> >> context >> >> > so that at the end of the route it will get called (without explici= tly >> >> > setting it) For example: >> >> > from("jms:somequeue") >> >> > .processRef("someRandomProcessor") >> >> > .processRef("someProcessorThatSetsThreadLocalValue") >> >> > .... >> >> > .to("jms:someotherqueue") >> >> > >> >> > >> >> > Ideally I'd like the threadlocal cleared when the exchange has been >> >> written >> >> > to the queue, without adding a processor that explicitly clears it = (as >> >> > developers when adding new routes will forget to do it). I know the >> >> > onCompletion runs in a seperate thread so isn't fit for my purpose. >> I've >> >> > noticed syncronisations and unitofworks, but cant seem to find any >> >> > documentation on it. Would this be fit for purpose? >> >> > >> >> > >> >> > >> >> > -- >> >> > View this message in context: >> >> >> http://camel.465427.n5.nabble.com/Clearing-ThreadLocal-when-exchange-com= pletes-tp5729849.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: cibsen@redhat.com >> >> Web: http://fusesource.com >> >> Twitter: davsclaus >> >> Blog: http://davsclaus.com >> >> Author of Camel in Action: http://www.manning.com/ibsen >> >> >> >> >> >> -- >> 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 >> --=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