You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ankelee <an...@gmail.com> on 2010/02/17 17:04:16 UTC

Keep original message several "steps" back.

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?
-- 
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.


Re: Keep original message several "steps" back.

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Feb 18, 2010 at 10:52 PM, ankelee <an...@gmail.com> wrote:
>
> I mean documenting using the system/routes by drawing diagrams with the
> symbols for the patterns from the EIP book.
>

The EIP book is a bit vague on error handling and its centered about MOM.
http://en.wikipedia.org/wiki/Message-oriented_middleware

And thus the Dead Letter Channel is kinda the error handler :)
So that is your symbol :)

>
> Claus Ibsen-2 wrote:
>>
>> On Thu, Feb 18, 2010 at 12:52 PM, ankelee <an...@gmail.com> wrote:
>>>
>>> On another note:
>>> I'm trying to design this system using the EIP visual notation. I'm not
>>> sure
>>> how to go about this and error handling in general. Are these types of
>>> things supposed to be left out and implicitly handled by the messagning
>>> system, or what is the general practice here?
>>>
>>
>> What do you mean by visual EIP? Do you use FUSE Integration Designer
>> or other graphical tooling?
>>
>> There is no true story about error handling. Its hard and you gotta
>> deal with it per use case.
>>
>>
>>>
>>>
>>> Claus Ibsen-2 wrote:
>>>>
>>>> On Wed, Feb 17, 2010 at 8:01 PM, ankelee <an...@gmail.com>
>>>> wrote:
>>>>>
>>>>> 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?
>>>>
>>>> The file component can do this by default using these options:
>>>> moveFailed = move to a error folder if processing of the file failed
>>>> move = move to a backup folder if processing succeeded
>>>>
>>>> http://camel.apache.org/file2.html
>>>>
>>>> So is this not something like that you want to do?
>>>>
>>>>
>>>>
>>>>>
>>>>> 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 <an...@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
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> 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.
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> 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.-tp27626057p27637396.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.-tp27626057p27646285.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

Re: Keep original message several "steps" back.

Posted by ankelee <an...@gmail.com>.
I mean documenting using the system/routes by drawing diagrams with the
symbols for the patterns from the EIP book.


Claus Ibsen-2 wrote:
> 
> On Thu, Feb 18, 2010 at 12:52 PM, ankelee <an...@gmail.com> wrote:
>>
>> On another note:
>> I'm trying to design this system using the EIP visual notation. I'm not
>> sure
>> how to go about this and error handling in general. Are these types of
>> things supposed to be left out and implicitly handled by the messagning
>> system, or what is the general practice here?
>>
> 
> What do you mean by visual EIP? Do you use FUSE Integration Designer
> or other graphical tooling?
> 
> There is no true story about error handling. Its hard and you gotta
> deal with it per use case.
> 
> 
>>
>>
>> Claus Ibsen-2 wrote:
>>>
>>> On Wed, Feb 17, 2010 at 8:01 PM, ankelee <an...@gmail.com>
>>> wrote:
>>>>
>>>> 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?
>>>
>>> The file component can do this by default using these options:
>>> moveFailed = move to a error folder if processing of the file failed
>>> move = move to a backup folder if processing succeeded
>>>
>>> http://camel.apache.org/file2.html
>>>
>>> So is this not something like that you want to do?
>>>
>>>
>>>
>>>>
>>>> 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 <an...@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
>>>>>
>>>>>
>>>>
>>>> --
>>>> 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.
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> 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.-tp27626057p27637396.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.-tp27626057p27646285.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Keep original message several "steps" back.

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Feb 18, 2010 at 12:52 PM, ankelee <an...@gmail.com> wrote:
>
> On another note:
> I'm trying to design this system using the EIP visual notation. I'm not sure
> how to go about this and error handling in general. Are these types of
> things supposed to be left out and implicitly handled by the messagning
> system, or what is the general practice here?
>

What do you mean by visual EIP? Do you use FUSE Integration Designer
or other graphical tooling?

There is no true story about error handling. Its hard and you gotta
deal with it per use case.


>
>
> Claus Ibsen-2 wrote:
>>
>> On Wed, Feb 17, 2010 at 8:01 PM, ankelee <an...@gmail.com> wrote:
>>>
>>> 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?
>>
>> The file component can do this by default using these options:
>> moveFailed = move to a error folder if processing of the file failed
>> move = move to a backup folder if processing succeeded
>>
>> http://camel.apache.org/file2.html
>>
>> So is this not something like that you want to do?
>>
>>
>>
>>>
>>> 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 <an...@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
>>>>
>>>>
>>>
>>> --
>>> 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.
>>>
>>>
>>
>>
>>
>> --
>> 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.-tp27626057p27637396.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

Re: Keep original message several "steps" back.

Posted by ankelee <an...@gmail.com>.
On another note:
I'm trying to design this system using the EIP visual notation. I'm not sure
how to go about this and error handling in general. Are these types of
things supposed to be left out and implicitly handled by the messagning
system, or what is the general practice here?



Claus Ibsen-2 wrote:
> 
> On Wed, Feb 17, 2010 at 8:01 PM, ankelee <an...@gmail.com> wrote:
>>
>> 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?
> 
> The file component can do this by default using these options:
> moveFailed = move to a error folder if processing of the file failed
> move = move to a backup folder if processing succeeded
> 
> http://camel.apache.org/file2.html
> 
> So is this not something like that you want to do?
> 
> 
> 
>>
>> 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 <an...@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
>>>
>>>
>>
>> --
>> 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.
>>
>>
> 
> 
> 
> -- 
> 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.-tp27626057p27637396.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Keep original message several "steps" back.

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Feb 18, 2010 at 1:07 AM, ankelee <an...@gmail.com> wrote:
>
> An upgrade from Camel 2.1.0 to 2.2.0 seems to fix the issue, this is a
> plausible cause?
>

Yeah I think there was a bug when setting that option under certain conditions.


>
>
>
> ankelee wrote:
>>
>> Yes that indeed looks like exactly what I want.
>>
>>         context.addRoutes(new RouteBuilder() {
>>             public void configure() {
>>
>> from("file://data/inbox?move=data/backup&moveFailed=data/error")
>>                       .to("xslt://file:Schemas/Common/Xslt/x-to-y.xsl")
>>                       .to("xslt://file:Schemas/Common/Xslt/y-to-z.xsl")
>>                       .to("file:data/outbox");
>>             }
>>         });
>>
>> What qualifies as a succeeded processing though and which errors does it
>> react to? The "move" works fine, but then I tried to introduce a flaw in
>> my input file which obviously gives me an exception, Camel creates the
>> error folder, but the file still only sits in the source directory, can
>> you explain further?
>>
>>
>> Claus Ibsen-2 wrote:
>>>
>>> On Wed, Feb 17, 2010 at 8:01 PM, ankelee <an...@gmail.com> wrote:
>>>>
>>>> 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?
>>>
>>> The file component can do this by default using these options:
>>> moveFailed = move to a error folder if processing of the file failed
>>> move = move to a backup folder if processing succeeded
>>>
>>> http://camel.apache.org/file2.html
>>>
>>> So is this not something like that you want to do?
>>>
>>>
>>>
>>>>
>>>> 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 <an...@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
>>>>>
>>>>>
>>>>
>>>> --
>>>> 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.
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> 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.-tp27626057p27632561.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

Re: Keep original message several "steps" back.

Posted by ankelee <an...@gmail.com>.
An upgrade from Camel 2.1.0 to 2.2.0 seems to fix the issue, this is a
plausible cause?




ankelee wrote:
> 
> Yes that indeed looks like exactly what I want.
> 
>         context.addRoutes(new RouteBuilder() {
>             public void configure() {
>                
> from("file://data/inbox?move=data/backup&moveFailed=data/error")
>                 	.to("xslt://file:Schemas/Common/Xslt/x-to-y.xsl")
>                 	.to("xslt://file:Schemas/Common/Xslt/y-to-z.xsl")
>                 	.to("file:data/outbox");
>             }
>         });
> 
> What qualifies as a succeeded processing though and which errors does it
> react to? The "move" works fine, but then I tried to introduce a flaw in
> my input file which obviously gives me an exception, Camel creates the
> error folder, but the file still only sits in the source directory, can
> you explain further?
> 
> 
> Claus Ibsen-2 wrote:
>> 
>> On Wed, Feb 17, 2010 at 8:01 PM, ankelee <an...@gmail.com> wrote:
>>>
>>> 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?
>> 
>> The file component can do this by default using these options:
>> moveFailed = move to a error folder if processing of the file failed
>> move = move to a backup folder if processing succeeded
>> 
>> http://camel.apache.org/file2.html
>> 
>> So is this not something like that you want to do?
>> 
>> 
>> 
>>>
>>> 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 <an...@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
>>>>
>>>>
>>>
>>> --
>>> 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.
>>>
>>>
>> 
>> 
>> 
>> -- 
>> 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.-tp27626057p27632561.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Keep original message several "steps" back.

Posted by ankelee <an...@gmail.com>.
Yes that indeed looks like exactly what I want.

        context.addRoutes(new RouteBuilder() {
            public void configure() {
               
from("file://data/inbox?move=data/backup&moveFailed=data/error")
                	.to("xslt://file:Schemas/Common/Xslt/x-to-y.xsl")
                	.to("xslt://file:Schemas/Common/Xslt/y-to-z.xsl")
                	.to("file:data/outbox");
            }
        });

What qualifies as a succeeded processing though and which errors does it
react to? The "move" works fine, but then I tried to introduce a flaw in my
input file which obviously gives me an exception, Camel creates the error
folder, but the file still only sits in the source directory, can you
explain further?


Claus Ibsen-2 wrote:
> 
> On Wed, Feb 17, 2010 at 8:01 PM, ankelee <an...@gmail.com> wrote:
>>
>> 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?
> 
> The file component can do this by default using these options:
> moveFailed = move to a error folder if processing of the file failed
> move = move to a backup folder if processing succeeded
> 
> http://camel.apache.org/file2.html
> 
> So is this not something like that you want to do?
> 
> 
> 
>>
>> 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 <an...@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
>>>
>>>
>>
>> --
>> 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.
>>
>>
> 
> 
> 
> -- 
> 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.-tp27626057p27631906.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Keep original message several "steps" back.

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Feb 17, 2010 at 8:01 PM, ankelee <an...@gmail.com> wrote:
>
> 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?

The file component can do this by default using these options:
moveFailed = move to a error folder if processing of the file failed
move = move to a backup folder if processing succeeded

http://camel.apache.org/file2.html

So is this not something like that you want to do?



>
> 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 <an...@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
>>
>>
>
> --
> 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.
>
>



-- 
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

Re: Keep original message several "steps" back.

Posted by ankelee <an...@gmail.com>.
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 <an...@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
> 
> 

-- 
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.


Re: Keep original message several "steps" back.

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Feb 17, 2010 at 5:04 PM, ankelee <an...@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