public class InstrumentationProcessor extends DelegateAsyncProcessor implements CamelInternalProcessorAdvice<StopWatch>, Ordered
ManagedCounter
for instrumenting
processing of exchanges.
This implementation has been optimised to work in dual mode, either as an advice or as a processor.
The former is faster and the latter is required when the error handler has been configured with redelivery enabled.processor
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
Constructor and Description |
---|
InstrumentationProcessor(String type,
Processor processor) |
Modifier and Type | Method and Description |
---|---|
void |
after(Exchange exchange,
StopWatch watch)
Callback executed after processing a step in the route.
|
StopWatch |
before(Exchange exchange)
Callback executed before processing a step in the route.
|
protected void |
beginTime(Exchange exchange) |
int |
getOrder()
Gets the order.
|
String |
getType() |
boolean |
process(Exchange exchange,
AsyncCallback callback)
Processes the message exchange.
|
protected void |
recordTime(Exchange exchange,
long duration) |
void |
setCounter(Object counter) |
void |
setType(String type) |
String |
toString() |
doShutdown, doStart, doStop, getProcessor, hasNext, next, process, processNext, setProcessor, setProcessor
doResume, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
public InstrumentationProcessor(String type, Processor processor)
public void setCounter(Object counter)
public boolean process(Exchange exchange, AsyncCallback callback)
AsyncProcessor
Processor.process(org.apache.camel.Exchange)
, but the caller supports having the exchange asynchronously processed.
If there was a failure processing then the caused Exception
would be set on the Exchange
.process
in interface AsyncProcessor
process
in class DelegateAsyncProcessor
exchange
- the message exchangecallback
- the AsyncCallback
will be invoked when the processing of the exchange is completed.
If the exchange is completed synchronously, then the callback is also invoked synchronously.
The callback should therefore be careful of starting recursive loop.protected void recordTime(Exchange exchange, long duration)
public StopWatch before(Exchange exchange) throws Exception
CamelInternalProcessorAdvice
before
in interface CamelInternalProcessorAdvice<StopWatch>
exchange
- the current exchangeCamelInternalProcessorAdvice.after(org.apache.camel.Exchange, Object)
method, or use null for no state.Exception
- is thrown if error during the call.public void after(Exchange exchange, StopWatch watch) throws Exception
CamelInternalProcessorAdvice
after
in interface CamelInternalProcessorAdvice<StopWatch>
exchange
- the current exchangewatch
- the state, if any, returned in the CamelInternalProcessorAdvice.before(org.apache.camel.Exchange)
method.Exception
- is thrown if error during the call.public String toString()
toString
in class DelegateAsyncProcessor
public int getOrder()
Ordered
Integer.MAX_VALUE
or eg Ordered.LOWEST
.Apache Camel