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 64C6ECF7D for ; Thu, 5 Jun 2014 17:54:42 +0000 (UTC) Received: (qmail 70476 invoked by uid 500); 5 Jun 2014 17:54:42 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 70429 invoked by uid 500); 5 Jun 2014 17:54:42 -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 70416 invoked by uid 99); 5 Jun 2014 17:54:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Jun 2014 17:54:42 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of kraythe@gmail.com designates 209.85.220.181 as permitted sender) Received: from [209.85.220.181] (HELO mail-vc0-f181.google.com) (209.85.220.181) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Jun 2014 17:54:39 +0000 Received: by mail-vc0-f181.google.com with SMTP id hq11so1582582vcb.12 for ; Thu, 05 Jun 2014 10:54:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=JTlouELgQjwDWEas+R1jt6vD0P4yjQ78wIxfkMc6XPU=; b=piebXu/rLQDqWFuT9jB0BeghZYlx+fBCJmpdOV5YhX3VenpszNbdL830DL9ufQuuZm CwGqczskPhOKJ6d9b7Qv2Q2LcPhjhJXEv+xk3re0XG7Lj7wDSv00AUhAndE073CS8iAD MnOKLyg4IM5L8hjX+Z+8TVCz3ws/tijyVMvUweBwWSUi0kd0GfXD79Gk1Bx6wUhssryD Yu6uXq7TUETnmaOpyGOyMeRisfKb+myi8pnxSveeu7SV+hieI6PUdKRCy4Cpul2UK3Ma 5fXalZ+szUTqFbyqTlu8WAJaJENC+dHGgF7G10UV25zkTevgtg1ZH2ORhCxzNeXztf2M 0ddQ== MIME-Version: 1.0 X-Received: by 10.58.227.193 with SMTP id sc1mr4111062vec.43.1401990854998; Thu, 05 Jun 2014 10:54:14 -0700 (PDT) Received: by 10.58.110.66 with HTTP; Thu, 5 Jun 2014 10:54:14 -0700 (PDT) In-Reply-To: References: Date: Thu, 5 Jun 2014 12:54:14 -0500 Message-ID: Subject: Re: Missing Important Use Case in Camel - Enrich current exchange using Consumer From: "kraythe ." To: Camel Users List Content-Type: multipart/alternative; boundary=047d7bd6b87ce400d804fb1a6eb8 X-Virus-Checked: Checked by ClamAV on apache.org --047d7bd6b87ce400d804fb1a6eb8 Content-Type: text/plain; charset=UTF-8 Actually I don't think the semantics need to change with the exception of enhancing the enrich EIP to include a synchronous on demand pull. You have enrich and pollEnrich and what we need is consumeEnrich. Then if the components support the activity (which should use nearly the same identical code) it should all be magic. I don't think there is a fundamental issue here and a small change could fix the functionality gap. *Robert Simmons Jr. MSc. - Lead Java Architect @ EA* *Author of: Hardcore Java (2003) and Maintainable Java (2012)* *LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39 * On Thu, Jun 5, 2014 at 9:21 AM, Camel Guy wrote: > When I first started using Camel, I thought it was strange that the mongodb > component returned data via instead of . Eventually I > figured it out. BTW, I still haven't memorized the definitions of producer > and consumer in Camelspeak because I can't keep them straight. > > Similar to your message queue example, I load data from the mail component > on-demand. I create a route on the fly and remove it when all mail has been > consumed (I had to modify the component to make that happen - I will submit > a patch when I have implemented something that doesn't look like botched > surgery and I have finished other mods). > > Anyone who has ever tried removing a route knows that it ain't pretty. > Underneath the covers, the overhead in terms of memory and other resources > (eg thread) of creating and removing routes is not trivial. > > I think has its place (asynchronous 'static' processing - such as > reading from the same JMS queue for eternity) but component designers need > to support as well, like the mongodb example. If "dynamic on-demand > > > ~cg > > > > On Wed, Jun 4, 2014 at 10:36 PM, Claus Ibsen > wrote: > > > On Thu, Jun 5, 2014 at 2:06 AM, Henrique Viecili > > wrote: > > > I faced the same issue in similar scenarios which forced me to use > Claim > > > Check in the aggregation strategy. I cannot recall exactly the reason, > > but > > > if I'm not wrong a while ago Claus commented about this limitation here > > in > > > the mailing list. > > > > > > > Yeah see the content enricher eip page, about pollEnrich, and the red > > box on that page. > > And we got a JIRA ticket to improved this. But requires an API change > > for Camel 3.0. > > > > > > > Anyway, it would be a great improvement. > > > > > > Regards, > > > Henriqeu Viecili > > > > > > Henrique Viecili > > > > > > > > > On 5 June 2014 00:47, kraythe . wrote: > > > > > >> I am working on some routes which use servlet: endpoints to create a > > REST > > >> api for a Ajax UI application. While working on it I am constantly > > plagued > > >> by the thought that there is a missing use case, a massive one in > camel. > > >> > > >> Suppose you want to serve a file to a user. They send you some > parameter > > >> and you use that to select the appropriate file to return. Currently > > there > > >> is no way to do such a thing with camel, so you are forced to use a > > >> processor and implement the logic yourself. What you need to do is > > enrich > > >> the current exchange with information from outside that exchange but > in > > a > > >> consumer manner. What you really need is something like: > > >> > > >> from("servlet:downloadFile") > > >> // logic to figure out what filename > > >> .enrich("file://a/b/c") > > >> .end(); > > >> > > >> Sure this particular use case can be implemented with a processor: > > >> > > >> from("servlet:downloadFile) > > >> // logic to figure out what filename > > >> .process(new Processor() { > > >> public void process(final Exchange exchange) { > > >> // code to create an IOStream and set it as body. > > >> } > > >> } > > >> > > >> This is an acceptable workaround in this case but it violates the > > beautiful > > >> component architecture. If I wanted to enrich from a JMS queue > > >> ("servlet:nextTicket") I would have to implement queue connectivity > > myself. > > >> Less than sub par. > > >> > > >> It seems to me that camel needs to have a new use case > "consumeEnrich()" > > >> where a consumer can be fired and then aggregated into the current > > >> exchange. In order to support this we need to add the ability for > > on-demand > > >> consumption: i.e. > > >> > > >> public interface SupportsConsumeEnrich { > > >> public Exchange consumeNow(); > > >> } > > >> > > >> Any endpoint that then implements SupportsConsumeEnrich can then be > > used in > > >> the consumeEnrich DSL. What do you think? > > >> > > >> *Robert Simmons Jr. MSc. - Lead Java Architect @ EA* > > >> *Author of: Hardcore Java (2003) and Maintainable Java (2012)* > > >> *LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39 > > >> * > > >> > > > > > > > > -- > > Claus Ibsen > > ----------------- > > Red Hat, Inc. > > Email: cibsen@redhat.com > > Twitter: davsclaus > > Blog: http://davsclaus.com > > Author of Camel in Action: http://www.manning.com/ibsen > > hawtio: http://hawt.io/ > > fabric8: http://fabric8.io/ > > > --047d7bd6b87ce400d804fb1a6eb8--