As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.
Questo contenuto non è disponibile nella lingua selezionata.
17.7. Use Exchange Properties
As only one instance of auditor is created by default and there is no guarantee for dispatching order, ensure that the custom auditors do not preserve state inside any of the fields. If you want to store values, use exchange properties or message headers. Here is an example of how to count processing time using Exchange properties as temporary storage:
@Named("custom auditor")
public class SimpleAuditor implements Auditor {
private Logger _logger = Logger.getLogger(SimpleAuditor.class);
@Override
public void beforeCall(Processors processor, Exchange exchange) {
exchange.setProperty("time", System.currentTimeMillis());
}
@Override
public void afterCall(Processors processor, Exchange exchange) {
long time = System.currentTimeMillis() - exchange.getProperty("time", 0, Long.class);
_logger.info("Step " + processor.name() + " took " + time + "ms");
}
}
@Named("custom auditor")
public class SimpleAuditor implements Auditor {
private Logger _logger = Logger.getLogger(SimpleAuditor.class);
@Override
public void beforeCall(Processors processor, Exchange exchange) {
exchange.setProperty("time", System.currentTimeMillis());
}
@Override
public void afterCall(Processors processor, Exchange exchange) {
long time = System.currentTimeMillis() - exchange.getProperty("time", 0, Long.class);
_logger.info("Step " + processor.name() + " took " + time + "ms");
}
}
Copy to ClipboardCopied!Toggle word wrapToggle overflow
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.