org.apache.camel.processor.interceptor
Class BacklogTracer

java.lang.Object
  extended by org.apache.camel.support.ServiceSupport
      extended by org.apache.camel.processor.interceptor.BacklogTracer
All Implemented Interfaces:
Service, ShutdownableService, InterceptStrategy, StatefulService, SuspendableService

public class BacklogTracer
extends ServiceSupport
implements InterceptStrategy

A tracer used for message tracing, storing a copy of the message details in a backlog.

This tracer allows to store message tracers per node in the Camel routes. The tracers is stored in a backlog queue (FIFO based) which allows to pull the traced messages on demand.


Field Summary
static int MAX_BACKLOG_SIZE
           
 
Fields inherited from class org.apache.camel.support.ServiceSupport
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
 
Constructor Summary
BacklogTracer(CamelContext camelContext)
           
 
Method Summary
 void clear()
           
static BacklogTracer createTracer(CamelContext context)
          Creates a new backlog tracer.
protected  void doStart()
          Implementations override this method to support customized start/stop.
protected  void doStop()
          Implementations override this method to support customized start/stop.
 List<BacklogTracerEventMessage> dumpAllTracedMessages()
           
 String dumpAllTracedMessagesAsXml()
           
 List<BacklogTracerEventMessage> dumpTracedMessages(String nodeId)
           
 String dumpTracedMessagesAsXml(String nodeId)
           
 int getBacklogSize()
           
static BacklogTracer getBacklogTracer(CamelContext context)
          A helper method to return the BacklogTracer instance if one is enabled
 int getBodyMaxChars()
           
 Queue<DefaultBacklogTracerEventMessage> getQueue()
           
 long getTraceCounter()
           
 String getTraceFilter()
           
 String getTracePattern()
           
 long incrementTraceCounter()
           
 boolean isBodyIncludeFiles()
           
 boolean isBodyIncludeStreams()
           
 boolean isEnabled()
           
 boolean isRemoveOnDump()
           
 void resetTraceCounter()
           
 void setBacklogSize(int backlogSize)
           
 void setBodyIncludeFiles(boolean bodyIncludeFiles)
           
 void setBodyIncludeStreams(boolean bodyIncludeStreams)
           
 void setBodyMaxChars(int bodyMaxChars)
           
 void setEnabled(boolean enabled)
           
 void setRemoveOnDump(boolean removeOnDump)
           
 void setTraceFilter(String filter)
           
 void setTracePattern(String tracePattern)
           
 boolean shouldTrace(ProcessorDefinition<?> definition, Exchange exchange)
          Whether or not to trace the given processor definition.
 Processor wrapProcessorInInterceptors(CamelContext context, ProcessorDefinition<?> definition, Processor target, Processor nextTarget)
          Deprecated. 
 
Methods inherited from class org.apache.camel.support.ServiceSupport
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, resume, shutdown, start, stop, suspend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_BACKLOG_SIZE

public static final int MAX_BACKLOG_SIZE
See Also:
Constant Field Values
Constructor Detail

BacklogTracer

public BacklogTracer(CamelContext camelContext)
Method Detail

getQueue

public Queue<DefaultBacklogTracerEventMessage> getQueue()

wrapProcessorInInterceptors

@Deprecated
public Processor wrapProcessorInInterceptors(CamelContext context,
                                                        ProcessorDefinition<?> definition,
                                                        Processor target,
                                                        Processor nextTarget)
                                      throws Exception
Deprecated. 

Description copied from interface: InterceptStrategy
This method is invoked by ProcessorDefinition.wrapProcessor(RouteContext, Processor) to give the implementor an opportunity to wrap the target processor in a route.

Important: See the class javadoc for advice on letting interceptor be compatible with the asynchronous routing engine.

Specified by:
wrapProcessorInInterceptors in interface InterceptStrategy
Parameters:
context - Camel context
definition - the model this interceptor represents
target - the processor to be wrapped
nextTarget - the next processor to be routed to
Returns:
processor wrapped with an interceptor or not wrapped.
Throws:
Exception - can be thrown

createTracer

public static BacklogTracer createTracer(CamelContext context)
Creates a new backlog tracer.

Parameters:
context - Camel context
Returns:
a new backlog tracer

getBacklogTracer

public static BacklogTracer getBacklogTracer(CamelContext context)
A helper method to return the BacklogTracer instance if one is enabled

Returns:
the backlog tracer or null if none can be found

shouldTrace

public boolean shouldTrace(ProcessorDefinition<?> definition,
                           Exchange exchange)
Whether or not to trace the given processor definition.

Parameters:
definition - the processor definition
exchange - the exchange
Returns:
true to trace, false to skip tracing

isEnabled

public boolean isEnabled()

setEnabled

public void setEnabled(boolean enabled)

getBacklogSize

public int getBacklogSize()

setBacklogSize

public void setBacklogSize(int backlogSize)

isRemoveOnDump

public boolean isRemoveOnDump()

setRemoveOnDump

public void setRemoveOnDump(boolean removeOnDump)

getBodyMaxChars

public int getBodyMaxChars()

setBodyMaxChars

public void setBodyMaxChars(int bodyMaxChars)

isBodyIncludeStreams

public boolean isBodyIncludeStreams()

setBodyIncludeStreams

public void setBodyIncludeStreams(boolean bodyIncludeStreams)

isBodyIncludeFiles

public boolean isBodyIncludeFiles()

setBodyIncludeFiles

public void setBodyIncludeFiles(boolean bodyIncludeFiles)

getTracePattern

public String getTracePattern()

setTracePattern

public void setTracePattern(String tracePattern)

getTraceFilter

public String getTraceFilter()

setTraceFilter

public void setTraceFilter(String filter)

getTraceCounter

public long getTraceCounter()

resetTraceCounter

public void resetTraceCounter()

dumpTracedMessages

public List<BacklogTracerEventMessage> dumpTracedMessages(String nodeId)

dumpTracedMessagesAsXml

public String dumpTracedMessagesAsXml(String nodeId)

dumpAllTracedMessages

public List<BacklogTracerEventMessage> dumpAllTracedMessages()

dumpAllTracedMessagesAsXml

public String dumpAllTracedMessagesAsXml()

clear

public void clear()

incrementTraceCounter

public long incrementTraceCounter()

doStart

protected void doStart()
                throws Exception
Description copied from class: ServiceSupport
Implementations override this method to support customized start/stop.

Important: See ServiceSupport.doStop() for more details.

Specified by:
doStart in class ServiceSupport
Throws:
Exception
See Also:
ServiceSupport.doStop()

doStop

protected void doStop()
               throws Exception
Description copied from class: ServiceSupport
Implementations override this method to support customized start/stop.

Important: Camel will invoke this ServiceSupport.doStop() method when the service is being stopped. This method will also be invoked if the service is still in uninitialized state (eg has not been started). The method is always called to allow the service to do custom logic when the service is being stopped, such as when CamelContext is shutting down.

Specified by:
doStop in class ServiceSupport
Throws:
Exception
See Also:
ServiceSupport.doStart()


Apache Camel