Defining completion actions dynamically
We have seen in the previous recipe how confirming and cancelling notifications can be defined at a route or global level, so that they can be triggered when an exchange completes processing. This is useful when that logic is tied to a single route, but how do you handle code called from multiple routes that need to do some sort of cleanup upon route completion?
This recipe will show you how to dynamically apply completion steps to an exchange's processing through the use of a Synchronization
class.
This mechanism is useful when you manipulate a class of resources that need some form of post-processing in the same way. For example, Camel uses this mechanism as a part of its file consumption to move or delete files after it has finished processing their contents. The fact that post-processing happens is transparent to the developer who uses that resource.
Getting ready
The Java code for this recipe is located in the org.camelcookbook.error.synchronizations...