Return-Path: Delivered-To: apmail-camel-users-archive@www.apache.org Received: (qmail 87281 invoked from network); 13 Apr 2010 07:16:29 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 13 Apr 2010 07:16:29 -0000 Received: (qmail 80888 invoked by uid 500); 13 Apr 2010 07:16:28 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 80790 invoked by uid 500); 13 Apr 2010 07:16: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 80782 invoked by uid 99); 13 Apr 2010 07:16:28 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Apr 2010 07:16:28 +0000 X-ASF-Spam-Status: No, hits=-1.0 required=10.0 tests=AWL,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of claus.ibsen@gmail.com designates 209.85.218.215 as permitted sender) Received: from [209.85.218.215] (HELO mail-bw0-f215.google.com) (209.85.218.215) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Apr 2010 07:16:24 +0000 Received: by bwz7 with SMTP id 7so2107263bwz.36 for ; Tue, 13 Apr 2010 00:16:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:received:message-id:subject:to:content-type :content-transfer-encoding; bh=HNJTglQpamVa7FwNZO1u5iOfYlNu+Jqnxoqcm5dYthY=; b=CVJQIiPCPOirvSti23MI4frNOwXhZyMjKaIeDiLrcCyyTJg+WdBFfjQIrY/K47DExz ChElZiiw2gpZLcFIAtGv7+N4my+C5CcWQ3D9xDtVYIBpEnTV99yqQpzXtr52gShGeG51 xpPPVBAZOTcDZjHVHwELZu3C+3wKs3T+RhMGA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=RihKfA85mg/ZWvFGSEE2WvYxMqIYJZeK6wLmrGjV0elZvRJGktCRi7CbM1OANndzE3 iWHYln4Q4nXmJKiNEptneHQwrWITdUbDfcmTZjbC2deBHduE9+XCMTQnueauhcTtIGaH izKnUNiFbrzXkKKtSqtG5Pk3QdkY+HoBONBFY= MIME-Version: 1.0 Received: by 10.204.72.141 with HTTP; Tue, 13 Apr 2010 00:15:42 -0700 (PDT) In-Reply-To: <28219199.post@talk.nabble.com> References: <28219199.post@talk.nabble.com> From: Claus Ibsen Date: Tue, 13 Apr 2010 09:15:42 +0200 Received: by 10.204.155.69 with SMTP id r5mr5992755bkw.0.1271142962232; Tue, 13 Apr 2010 00:16:02 -0700 (PDT) Message-ID: Subject: Re: Injecting ProducerTemplates, scoping, and JMX memleak To: users@camel.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Tue, Apr 13, 2010 at 1:22 AM, matthewm wrote: > > Hello, > > We are using Camel 2.2.0 with Spring 3.0.1.RELEASE in the context of a we= b > service. > > We've been using @EndpointInject to inject ProducerTemplates into our bea= ns. > Some of our beans are request scoped, and so a new ProducerTemplate is > created and injected on each request. > > After more study this seems to run counter to the idea of ProducerTemplat= e, > which appears to have been conceived as a long-lived object rather than > transient. =A0It seems perhaps the documentation of @EndpointInject might > point this out; injecting into singletons makes perfect sense but injecti= ng > into request-scoped beans may be undesirable. > The FAQ has some details on producer template http://camel.apache.org/why-does-camel-use-too-many-threads-with-producerte= mplate.html You can just use @Autowired or other Spring IoC stuff. @Autowired private ProducerTemplate template; Camel will automatic enlist a ProducerTemplate if you do not explict set a