Show Table of Contents
17.2. Enable Custom Auditors
Audit mechanism requires CDI runtime environment to run.
To enable custom auditors, define the Auditor implementations with the
@Named annotation. It helps Apache Camel component to recognize all the auditor implementations. Camel Exchange Bus, a default implementation used by SwitchYard, look up for bean definitions with @Audit annotation.
@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());
}
}
Note
Do not include any state inside the Custom Auditor's field. Red Hat recommends you to use exchange properties or message headers to store values.

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.