You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Tom1738 <to...@uk.fujitsu.com> on 2015/04/27 16:46:14 UTC

How to guarantee OnCompletion() is called before a file is routed further down the route

Hi

I am considering a new camel route implemented in java, something like,

	from(file://input).to(file:/middle).to(file:output).

I want to introduce a Synchronization.onComplete() operation after
"to(file://middle)" doing some housekeeping, such as checking the file has
been routed from "/input" to "/middle" and what size it is. 
However, I can't guarantee that the onComplete() callback will be invoked
BEFORE the file is routed from "/middle" to "/output". If that happens, the
housekeeping checks will fail its purpose (as the file is already moved to
"/output").

Can anyone out there let me know if there is some Apache Camel mechanism
that can guarantee the order of OnCompletion() coming before the file is
routed further down? If that's not available in Camel, any suggestions how I
can achieve the goal?



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-guarantee-OnCompletion-is-called-before-a-file-is-routed-further-down-the-route-tp5766386.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to guarantee OnCompletion() is called before a file is routed further down the route

Posted by Tom1738 <to...@uk.fujitsu.com>.
Hi,

what's meant by "the exchange is done being routed"? I reckon that's when
the exchange has been delivered from "input" to "middle" (using example in
my original post). 


Is that correct? If so, then my OnCompletion() can been called before the
file is moved to "output" or after. But there is no guarantee, is my
understanding correct?





--
View this message in context: http://camel.465427.n5.nabble.com/How-to-guarantee-OnCompletion-is-called-before-a-file-is-routed-further-down-the-route-tp5766386p5766391.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to guarantee OnCompletion() is called before a file is routed further down the route

Posted by Claus Ibsen <cl...@gmail.com>.
on completion is only for when the exchange is done being routed
totally. Not in between eips in routes.

You can add your task as a bean / processor step between the 2 eips.
Or look at interceptors and then only do your work after the middle
etc, but that takes a little bit of code to filter when to do the
work.

And there is also the event notifier you can look at.

On Mon, Apr 27, 2015 at 4:46 PM, Tom1738 <to...@uk.fujitsu.com> wrote:
> Hi
>
> I am considering a new camel route implemented in java, something like,
>
>         from(file://input).to(file:/middle).to(file:output).
>
> I want to introduce a Synchronization.onComplete() operation after
> "to(file://middle)" doing some housekeeping, such as checking the file has
> been routed from "/input" to "/middle" and what size it is.
> However, I can't guarantee that the onComplete() callback will be invoked
> BEFORE the file is routed from "/middle" to "/output". If that happens, the
> housekeeping checks will fail its purpose (as the file is already moved to
> "/output").
>
> Can anyone out there let me know if there is some Apache Camel mechanism
> that can guarantee the order of OnCompletion() coming before the file is
> routed further down? If that's not available in Camel, any suggestions how I
> can achieve the goal?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-guarantee-OnCompletion-is-called-before-a-file-is-routed-further-down-the-route-tp5766386.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
hawtio: http://hawt.io/
fabric8: http://fabric8.io/