Claus Ibsen-2 wrote > On Sun, Dec 2, 2012 at 4:52 PM, bung_ho < > bung_ho@
> > wrote: >> Thanks, but are you sure end() is being used to end the route there? It's >> not >> clear to me and I can't find any more documentation on end() anywhere. I >> saw >> this other example and it doesn't look like it's being used to end the >> route >> prematurely the way I'd like to. Note that in the XML version, there is >> no >> such "end" tag. >> >> http://fusesource.com/docs/router/2.2/eip/BasicPrinciples-ExceptionHandling-doTry.html >> >> I'd like to try it but I can't find any equivalent way to do it in XML, >> which is what we are using. >> > > I think he refers to > <stop/> > . Which will stop continue routing an exchange. > > > About the end, then its only available in Java DSL, because you need > it in situations to denote an endpoint ro an eip. > For example in XML you have > <split> > ... > ... > </split> > And where > </split> > marks the end of the split. In Java you can use > .end() for that instead > > split() > ... > ... > .end() Thanks Claus, that makes sense. I did read about doing stop() or stopRoute() but it seems that it is not advisable to do so from within the route itself, and that it is suggested to instead use a different route that calls stopRoute on the route I want to stop. However this becomes an asynchronous operation -- but I want to make sure that the route doesn't continue even 1 step on the other files, from the moment of the exception. It seems that stopping the route asynchronously from another route wouldn't guarantee this. Instead, I came up with a crude workaround. What I did was to use a bean to carry a static flag (actually a Hashtable of flags, containing a status for each different route). If one file fails processing, it sets the flag to an error condition. Then each subsequent iteration of the route (i.e., each run-thru for subsequent files in the batch) would check this flag and act accordingly (continue processing or not). Admittedly it is crude but it serves my purposes and since the route should only be run by one thread at any given time, seems reasonably safe to me. Is there a better way to do what I'm trying to do? (I also tried to use Exchange properties and even ThreadLocal variables instead of the static flag, but those get reset for each run-thru of the route). Thanks -- View this message in context: http://camel.465427.n5.nabble.com/how-to-break-out-of-a-batch-tp5723425p5723550.html Sent from the Camel - Users mailing list archive at Nabble.com.
