You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by a106562 <a1...@drdrb.net> on 2014/03/21 21:05:21 UTC

moving input message after routing ends

Hello community,

I have the following algorithm

1. Incoming message.
2. Fetch an object from db or remote service, which should be updated with
information from parsed message. Parsing may be complex
    a) if the object is not available, then create an new one and save it
into db. Notify user about new object. Move Message into .errors folder.
Stop Processing message.
    b) if the object is available, then update it and save. If some
properties are invalid stop processing. Move Message into .errors folder.
3. Fetch or create another object which should be processed with similar
logic like in step 2. But using remote web service
4. if one of steps fails with an Exception, then move original message into
.errors folder, otherwise copy into backup folder and .done folder

To be able to move/copy the input message from step 1, I've saved it into
properties. Then, for moving message at the end of each 'if' branch, I do 

setBody(property("input")).to("file:afolder")


I wonder, if there are any better ways, patterns to implement the algorithm



--
View this message in context: http://camel.465427.n5.nabble.com/moving-input-message-after-routing-ends-tp5749216.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: moving input message after routing ends

Posted by a106562 <a1...@drdrb.net>.
Hello,

I've tried moveFailed. It works fine if an error occurs. In my case there is
no error, it is just notification about new object(s), which should be
re-processed later, after approving by administrator. The file component
would move message then to .done folder, and not to .error folder as desired
in step 1a. I have to throw the exception to make it work.

Anyway, thanks for help!



--
View this message in context: http://camel.465427.n5.nabble.com/moving-input-message-after-routing-ends-tp5749216p5749244.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: moving input message after routing ends

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

The file component has a move and movedFailed option you can use
http://camel.apache.org/file2



On Fri, Mar 21, 2014 at 9:05 PM, a106562 <a1...@drdrb.net> wrote:
> Hello community,
>
> I have the following algorithm
>
> 1. Incoming message.
> 2. Fetch an object from db or remote service, which should be updated with
> information from parsed message. Parsing may be complex
>     a) if the object is not available, then create an new one and save it
> into db. Notify user about new object. Move Message into .errors folder.
> Stop Processing message.
>     b) if the object is available, then update it and save. If some
> properties are invalid stop processing. Move Message into .errors folder.
> 3. Fetch or create another object which should be processed with similar
> logic like in step 2. But using remote web service
> 4. if one of steps fails with an Exception, then move original message into
> .errors folder, otherwise copy into backup folder and .done folder
>
> To be able to move/copy the input message from step 1, I've saved it into
> properties. Then, for moving message at the end of each 'if' branch, I do
>
> setBody(property("input")).to("file:afolder")
>
>
> I wonder, if there are any better ways, patterns to implement the algorithm
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/moving-input-message-after-routing-ends-tp5749216.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
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
Make your Camel applications look hawt, try: http://hawt.io