Return-Path: Delivered-To: apmail-camel-users-archive@www.apache.org Received: (qmail 67667 invoked from network); 17 Feb 2010 19:02:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 17 Feb 2010 19:02:23 -0000 Received: (qmail 42436 invoked by uid 500); 17 Feb 2010 19:02:23 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 42408 invoked by uid 500); 17 Feb 2010 19:02:23 -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 42398 invoked by uid 99); 17 Feb 2010 19:02:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Feb 2010 19:02:23 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Feb 2010 19:02:12 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1Nhp9j-00021R-Eu for users@camel.apache.org; Wed, 17 Feb 2010 11:01:51 -0800 Message-ID: <27628689.post@talk.nabble.com> Date: Wed, 17 Feb 2010 11:01:51 -0800 (PST) From: ankelee To: users@camel.apache.org Subject: Re: Keep original message several "steps" back. In-Reply-To: <5380c69c1002170813u1951b121qa03f3f76b0975853@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: andreasasmuss@gmail.com References: <27626057.post@talk.nabble.com> <5380c69c1002170813u1951b121qa03f3f76b0975853@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org The latter two suggestions I can get to work, but I just get null when trying to get the body as a String. I'm not sure what is going on behind the scenes here. As stated I want to be able to recover from an exception if a transformation goes wrong and write the file to an error directory, and another directory if everything succeeds. Is Camel keeping the original file "safe" internally no matter which way I do it? Can I always use the file handle to get first original message? getUnitOfWork() will always refer to the original entry point of the message or? I thought it would only keep knowledge about the latest node that the message had been through. Claus Ibsen-2 wrote: > > On Wed, Feb 17, 2010 at 5:04 PM, ankelee wrote: >> >> Hello >> >> I'm trying to build a system where I consume files from a directory, >> perform >> transformations in several steps and finally deliver at an endpoint. In >> case >> the delivery of the transformed message succeeds, I want to route a copy >> of >> the original file as it was before consumation to a backup directory on >> disk. If the transformation fails, I want a copy of the original file >> copied >> to an error directory. >> >> I have thought up a couple of solutions but I don't think they are best >> practice. One is somehow keeping a copy in a queue and then going back >> and >> identifying on an id and copy the. The other one is bundling the original >> file with the transforming message and then extracting the original file >> and >> write it to the according directory/queue. >> >> What kind of approach would be good? >> -- > > In the future Camel will have a some sort of better API to traverse > the message history so you can see the modifications. > > Anyway the original input message is avail as follows > > Exchange exchange = ... > > Message in = exchange.getUnitOfWork().getOriginalInMessage(); > // will read the file content > String body = in.getBody(String.class); > > but as yours is a file you should be able to do > GenericFile file = in.getBody(GenericFile.class); > > if you want to use the file handle instead. > > > You can also just extract the file name from the header and do > > File file = new File(exchange.getIn().getHeader(Exchange.FILE_NAME, > String.class)); > > > >> View this message in context: >> http://old.nabble.com/Keep-original-message-several-%22steps%22-back.-tp27626057p27626057.html >> Sent from the Camel - Users mailing list archive at Nabble.com. >> >> > > > > -- > Claus Ibsen > Apache Camel Committer > > Author of Camel in Action: http://www.manning.com/ibsen/ > Open Source Integration: http://fusesource.com > Blog: http://davsclaus.blogspot.com/ > Twitter: http://twitter.com/davsclaus > > -- View this message in context: http://old.nabble.com/Keep-original-message-several-%22steps%22-back.-tp27626057p27628689.html Sent from the Camel - Users mailing list archive at Nabble.com.