That should be documented somewhere (maybe page oncompletion.html) as the javadoc is not sufficient enough as source of information for the end users.
On Thu, Oct 2, 2014 at 9:33 AM, Claus Ibsen <claus.ib...@gmail.com> wrote: > No please read the javadoc of > org.apache.camel.spi.SynchronizationRouteAware > > Its called 3 times because > - before routing > - after route > - done (either onComplete or onFailure) > > On Thu, Oct 2, 2014 at 9:17 AM, Charles Moulliard <ch0...@gmail.com> > wrote: > > Hi Max, > > > > Is it called 3 times because an exception has been throw in the route ? > Do > > you have a test case that we could use to have a look and reproduce the > > issue ? > > > > Regards, > > > > > > On Thu, Oct 2, 2014 at 5:21 AM, Max Bridgewater < > max.bridgewa...@gmail.com> > > wrote: > > > >> Some progress on this. It appears that in Camel 2.14, there is now an > >> interface called SynchronizationRouteAware in addition to > Synchronization. > >> SynchronizationRouteAwarehas two additional methods onAfterRoute and > >> onBeforeRoute. > >> > >> What I've done is implement onAfterRoute and call my completion logic > >> there. I left onComplete and onBeforeRoute empty. > >> > >> Things seem to work well and the synchronization is called at the end of > >> the route as it was the case with Camel 2.13. The only caveat now is > that > >> the synchronization is being called 3 times instead of just once. > >> > >> Why is this? > >> > >> My Synchronization looks as follows: > >> > >> exchange.getUnitOfWork().addSynchronization( > >> SynchronizationRouteAware(){ > >> public void onAfterRoute(Route route, > Exchange > >> exchange){ > >> myCompletionLogic(exchange) > >> } > >> public void onBeforeRoute(Route route, Exchange > >> exchange){ > >> //Left Empty > >> } > >> public void myCompletionLogic(Exchange x){ > >> //My completion logic here > >> } > >> public void onComplete(Exchange x){ > >> //Left empty > >> } > >> public void onFailure(Exchange x){ > >> //Left empty > >> } > >> > >> } > >> > >> ); > >> > >> On Wed, Oct 1, 2014 at 2:35 PM, Max Bridgewater < > max.bridgewa...@gmail.com > >> > > >> wrote: > >> > >> > Hi, > >> > > >> > In Came 2.14, onCompletion now has a mode parameter that allows > >> > controlling if the onCompletion body is to be executed after or before > >> the > >> > route consumer. > >> > > >> > How does this impact UnitOfWork? Is there a way to also control when a > >> > synchronization is to be executed? > >> > > >> > I haven't fully isolated the issue yet. But I seem to have a case > where > >> > UnitOfWork was executed before the route consumer while with Camel > 2.14, > >> it > >> > is not executed after the route consumer has started. > >> > > >> > Any thoughts? > >> > > >> > Regards, > >> > Max. > >> > > >> > > >> > > > > > > > > -- > > Charles Moulliard > > Apache Committer / Architect @RedHat > > Twitter : @cmoulliard | Blog : http://cmoulliard.github.io > > > > -- > Claus Ibsen > ----------------- > Red Hat, Inc. > Email: cib...@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/ > -- Charles Moulliard Apache Committer / Architect @RedHat Twitter : @cmoulliard | Blog : http://cmoulliard.github.io