The aspect oriented programming (AOP) feature in Apache Camel enables you to apply before and after processing to a specified portion of a route. As a matter of fact, AOP does not provide anything that you could not do with the regular route syntax. The advantage of the AOP syntax, however, is that it enables you to specify before and after processing at a single point in the route. In some cases, this gives a more readable syntax. The typical use case for AOP is the application of a symmetrical pair of operations before and after a route fragment is processed. For example, typical pairs of operations that you might want to apply using AOP are: encrypt and decrypt; begin transaction and commit transaction; allocate resources and deallocate resources; and so on.
The aop element supports the following optional
attributes:
beforeUriafterUriafterFinallyUri
In the XML DSL, the route fragment to which you apply before and
after processing is enclosed in the aop element. For
example, Example 6.1 performs AOP processing around the route fragment
that calls the bean methods.
Example 6.1. Route using AOP
<route>
<from uri="jms:queue:inbox"/>
<aop beforeUri="log:before" afterUri="log:after">
<to uri="bean:order?method=validate"/>
<to uri="bean:order?method=handle"/>
</aop>
<to uri="jms:queue:order"/>
</route>The beforeUri attribute specifies the endpoint where
the exchange is routed before processing the route fragment, and
the afterUri attribute specifies the endpoint where the
exchange is routed after processing the route fragment.








