17.5. Create a Custom Auditor
Prerequisities
- CDI Runtime
- Annotate your auditor implementations with @Named in order to have Camel recognize them.NoteThe Camel Exchange Bus looks for bean definitions with the @Audit annotation.Here is code that shows what a very simple auditor would look like:
@Audit @Named("custom auditor") public class SimpleAuditor implements Auditor { @Override public void beforeCall(Processors processor, Exchange exchange) { System.out.println("Before " + processor.name()); } @Override public void afterCall(Processors processor, Exchange exchange) { System.out.println("After " + processor.name()); } }ImportantBe aware that the afterCall method is not called if the step it surrounds throws an exception. If this happens, afterCall will be skipped.
Result
You can see many statements like 'Before DOMAIN_HANDLERS' and 'Before ADDRESSING' appearing in the server console. This is because every step of mediation is surrounded by this SimpleAuditor class.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.