Questo contenuto non è disponibile nella lingua selezionata.

17.5. Create a Custom Auditor


Prerequisities

  • CDI Runtime
  • Annotate your auditor implementations with @Named in order to have Camel recognize them.
    Note
    The 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());
        }
     
    }
    
    Copy to Clipboard Toggle word wrap
    Important
    Be 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.

Torna in cima
Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Theme

© 2025 Red Hat