Return-Path: Delivered-To: apmail-activemq-camel-user-archive@locus.apache.org Received: (qmail 21757 invoked from network); 13 Dec 2007 16:12:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Dec 2007 16:12:16 -0000 Received: (qmail 78819 invoked by uid 500); 13 Dec 2007 16:12:05 -0000 Delivered-To: apmail-activemq-camel-user-archive@activemq.apache.org Received: (qmail 78801 invoked by uid 500); 13 Dec 2007 16:12:05 -0000 Mailing-List: contact camel-user-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: camel-user@activemq.apache.org Delivered-To: mailing list camel-user@activemq.apache.org Received: (qmail 78791 invoked by uid 99); 13 Dec 2007 16:12:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Dec 2007 08:12:05 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of james.strachan@gmail.com designates 209.85.162.177 as permitted sender) Received: from [209.85.162.177] (HELO el-out-1112.google.com) (209.85.162.177) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Dec 2007 16:11:41 +0000 Received: by el-out-1112.google.com with SMTP id j27so170916elf.0 for ; Thu, 13 Dec 2007 08:11:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=mOzKNtPme6ddP1Rzbo/EaDUX4Pt++KcLq0DfgwAR6sY=; b=vX3r19+ufsI/a3YupOpUYoqKhRhIdmPti+P7Mnm4vJDjaNKqMEMG+BFoNs85E5ToBC5iJeuwD7wvQ/SkhgPOp8Jt6/3Z0IMBRpNWmiqRNSX3QrZymSSbWqqLohDxSGHwqhA9vaOSq7pOiiI7muF/DjlhpL8WNAiRYkon1ixK5K4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Q5Riij8/Rxmf8uSPyu/3Jg7IKa6RWTGLoXloIfFdjR86chJ7A7QeO+6U4KS18EjFSUJMsps3UC0HKCfOWAzF4QF5bC0XYp2rcnVdGJcvUNiGs+V6YpE8XZ5hQuf7gyhM35al80AcmHOnco6RlNT2Uas/9iso34xLsUwBV6kUNrQ= Received: by 10.150.195.21 with SMTP id s21mr721977ybf.114.1197562303334; Thu, 13 Dec 2007 08:11:43 -0800 (PST) Received: by 10.150.148.20 with HTTP; Thu, 13 Dec 2007 08:11:43 -0800 (PST) Message-ID: Date: Thu, 13 Dec 2007 16:11:43 +0000 From: "James Strachan" To: camel-user@activemq.apache.org Subject: Re: Adding Components Dynamically In-Reply-To: <14317514.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <14317514.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org On 13/12/2007, ewhauser wrote: > Hi, > > I have a use case where we would like to have end users define BAM rules > that can be read by Camel. I would like to persist their criteria to a > database and then build the BAM rules dynamically at runtime. I might have > the need to do this with routes as well, but I am not entirely sure yet. That sounds fine - it should be trivial to create ActivityBuilder or RouteBuilder instances at runtime whenever you like and add them to a CamelContext. > I was investigating approaches for handling this, and I was thinking > something like: > > 1. GUI writes rules to the database and publishes a message to a topic > saying that rules have changed > 2. Have a subscriber read the rules from DB > 3. Get the CamelContext from the container and remove any rules that are > have changes or are deleted > 4. Add the rules to the CamelContext I guess it all comes down to how you specify the rules (what code, XML, SQL data is used). You could always write rules using Java code and/or Spring XML and make an OSGi bundle and deploy that into the database, then version/schedule them to go live on different dates/times etc? e.g. roll back / forward etc. Or if you can find some data in a database to represent the things which change, you could have a generic rulebase populate itself from some query or something? > This all certainly seems possible from an API standpoint, but can you alter > the CamelContext while you have active brokers processing messages? If yes, > are there any pitfalls to this approach? You can for sure. The simplest approach is to use one CamelContext per rulebase; then you can start & stop the whole thing easily in one unit. e.g. think of starting/stopping a Spring ApplicationContext; its kinda the same thing - as you deploy/undeploy multiple contexts it can get a bit confusing remembering whats what - whereas if you do it at the CamelContext / ApplicationContext its nice and simple. The same granularity of CamelContext works nicely with OSGI bundles too. -- James ------- http://macstrac.blogspot.com/ Open Source Integration http://open.iona.com