org.apache.camel.processor.interceptor
Class BacklogDebugger

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

public class BacklogDebugger
extends ServiceSupport
implements InterceptStrategy

A Debugger that has easy debugging functionality which can be used from JMX with ManagedBacklogDebuggerMBean.

This implementation allows to set breakpoints (with or without a condition) and inspect the Exchange dumped in XML in BacklogTracerEventMessage format. There is operations to resume suspended breakpoints to continue routing the Exchange. There is also step functionality so you can single step a given Exchange.

This implementation will only break the first Exchange that arrives to a breakpoint. If Camel routes using concurrency then sub-sequent Exchange will continue to be routed, if there breakpoint already holds a suspended Exchange.


Field Summary
 
Fields inherited from class org.apache.camel.support.ServiceSupport
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
 
Constructor Summary
BacklogDebugger(CamelContext camelContext)
           
 
Method Summary
 void addBreakpoint(String nodeId)
           
 void addConditionalBreakpoint(String nodeId, String language, String predicate)
           
 boolean afterProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition, long timeTaken)
           
 boolean beforeProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition)
           
 void disableBreakpoint(String nodeId)
           
 void disableDebugger()
           
protected  void doStart()
          Implementations override this method to support customized start/stop.
protected  void doStop()
          Implementations override this method to support customized start/stop.
 String dumpTracedMessagesAsXml(String nodeId)
           
 void enableBreakpoint(String nodeId)
           
 void enableDebugger()
           
static BacklogDebugger getBacklogDebugger(CamelContext context)
          A helper method to return the BacklogDebugger instance if one is enabled
 int getBodyMaxChars()
           
 Set<String> getBreakpoints()
           
 long getDebugCounter()
           
 Debugger getDebugger()
           
 String getLoggingLevel()
           
 Set<String> getSuspendedBreakpointNodeIds()
           
 boolean hasBreakpoint(String nodeId)
           
 boolean isBodyIncludeFiles()
           
 boolean isBodyIncludeStreams()
           
 boolean isEnabled()
           
 boolean isSingleStepMode()
           
 void removeAllBreakpoints()
           
 void removeBreakpoint(String nodeId)
           
 void resetDebugCounter()
           
 void resumeAll()
           
 void resumeBreakpoint(String nodeId)
           
 void setBodyIncludeFiles(boolean bodyIncludeFiles)
           
 void setBodyIncludeStreams(boolean bodyIncludeStreams)
           
 void setBodyMaxChars(int bodyMaxChars)
           
 void setLoggingLevel(String level)
           
 void setMessageBodyOnBreakpoint(String nodeId, String body)
           
 void setMessageHeaderOnBreakpoint(String nodeId, String headerName, String value)
           
 void step()
           
 void stepBreakpoint(String nodeId)
           
 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
 

Constructor Detail

BacklogDebugger

public BacklogDebugger(CamelContext camelContext)
Method Detail

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

getBacklogDebugger

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

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

getDebugger

public Debugger getDebugger()

getLoggingLevel

public String getLoggingLevel()

setLoggingLevel

public void setLoggingLevel(String level)

enableDebugger

public void enableDebugger()

disableDebugger

public void disableDebugger()

isEnabled

public boolean isEnabled()

hasBreakpoint

public boolean hasBreakpoint(String nodeId)

isSingleStepMode

public boolean isSingleStepMode()

addBreakpoint

public void addBreakpoint(String nodeId)

addConditionalBreakpoint

public void addConditionalBreakpoint(String nodeId,
                                     String language,
                                     String predicate)

removeBreakpoint

public void removeBreakpoint(String nodeId)

removeAllBreakpoints

public void removeAllBreakpoints()

getBreakpoints

public Set<String> getBreakpoints()

resumeBreakpoint

public void resumeBreakpoint(String nodeId)

setMessageBodyOnBreakpoint

public void setMessageBodyOnBreakpoint(String nodeId,
                                       String body)

setMessageHeaderOnBreakpoint

public void setMessageHeaderOnBreakpoint(String nodeId,
                                         String headerName,
                                         String value)

resumeAll

public void resumeAll()

stepBreakpoint

public void stepBreakpoint(String nodeId)

step

public void step()

getSuspendedBreakpointNodeIds

public Set<String> getSuspendedBreakpointNodeIds()

disableBreakpoint

public void disableBreakpoint(String nodeId)

enableBreakpoint

public void enableBreakpoint(String nodeId)

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)

dumpTracedMessagesAsXml

public String dumpTracedMessagesAsXml(String nodeId)

getDebugCounter

public long getDebugCounter()

resetDebugCounter

public void resetDebugCounter()

beforeProcess

public boolean beforeProcess(Exchange exchange,
                             Processor processor,
                             ProcessorDefinition<?> definition)

afterProcess

public boolean afterProcess(Exchange exchange,
                            Processor processor,
                            ProcessorDefinition<?> definition,
                            long timeTaken)

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