camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Keep original message several "steps" back.
Date Wed, 17 Feb 2010 16:13:15 GMT
On Wed, Feb 17, 2010 at 5:04 PM, ankelee <andreasasmuss@gmail.com> 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> 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

Mime
View raw message