Package org.apache.camel.impl.debugger
Class BacklogDebugger
java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.impl.debugger.BacklogDebugger
- All Implemented Interfaces:
AutoCloseable
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.StatefulService
,org.apache.camel.SuspendableService
public final class BacklogDebugger
extends org.apache.camel.support.service.ServiceSupport
A
Debugger
that has easy debugging functionality which can be used from JMX with
ManagedBacklogDebuggerMBean
.
This implementation allows setting 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 their breakpoint already holds a
suspended Exchange
.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The name of the environment variable that contains the value of the flag indicating whether theBacklogDebugger
should suspend processing the messages and wait for a debugger to attach or not.static final String
The name of the system property that contains the value of the flag indicating whether theBacklogDebugger
should suspend processing the messages and wait for a debugger to attach or not.Fields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addBreakpoint
(String nodeId) void
addConditionalBreakpoint
(String nodeId, String language, String predicate) void
afterProcess
(org.apache.camel.Exchange exchange, org.apache.camel.Processor processor, org.apache.camel.NamedNode definition, long timeTaken) void
attach()
Attach the debugger which will resume the message processing in case the suspend mode is enabled.org.apache.camel.util.StopWatch
beforeProcess
(org.apache.camel.Exchange exchange, org.apache.camel.Processor processor, org.apache.camel.NamedNode definition) static BacklogDebugger
createDebugger
(org.apache.camel.CamelContext context) Creates a new backlog debugger.void
detach()
Detach the debugger which will suspend the message processing in case the suspend mode is enabled.void
disableBreakpoint
(String nodeId) void
protected void
doStart()
protected void
doStop()
dumpTracedMessagesAsXml
(String nodeId) void
enableBreakpoint
(String nodeId) void
static BacklogDebugger
getBacklogDebugger
(org.apache.camel.CamelContext context) A helper method to return the BacklogDebugger instance if one is enabledint
long
long
org.apache.camel.Exchange
Gets the exchanged suspended at the given breakpoint id or null if there is none at that id.boolean
hasBreakpoint
(String nodeId) boolean
boolean
boolean
boolean
void
void
removeBreakpoint
(String nodeId) void
removeMessageBodyOnBreakpoint
(String nodeId) void
removeMessageHeaderOnBreakpoint
(String nodeId, String headerName) void
void
void
resumeBreakpoint
(String nodeId) void
setBodyIncludeFiles
(boolean bodyIncludeFiles) void
setBodyIncludeStreams
(boolean bodyIncludeStreams) void
setBodyMaxChars
(int bodyMaxChars) void
setFallbackTimeout
(long fallbackTimeout) void
setLoggingLevel
(String level) void
setMessageBodyOnBreakpoint
(String nodeId, Object body) void
setMessageBodyOnBreakpoint
(String nodeId, Object body, Class<?> type) void
setMessageHeaderOnBreakpoint
(String nodeId, String headerName, Object value) void
setMessageHeaderOnBreakpoint
(String nodeId, String headerName, Object value, Class<?> type) void
step()
void
stepBreakpoint
(String nodeId) Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.camel.Service
build, close, init, start, stop
Methods inherited from interface org.apache.camel.ShutdownableService
shutdown
Methods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending
Methods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Field Details
-
SUSPEND_MODE_ENV_VAR_NAME
The name of the environment variable that contains the value of the flag indicating whether theBacklogDebugger
should suspend processing the messages and wait for a debugger to attach or not.- See Also:
-
SUSPEND_MODE_SYSTEM_PROP_NAME
The name of the system property that contains the value of the flag indicating whether theBacklogDebugger
should suspend processing the messages and wait for a debugger to attach or not.- See Also:
-
-
Method Details
-
createDebugger
Creates a new backlog debugger.In case the environment variable
SUSPEND_MODE_ENV_VAR_NAME
or the system propertySUSPEND_MODE_SYSTEM_PROP_NAME
has been set totrue
, the message processing is directly suspended.- Parameters:
context
- Camel context- Returns:
- a new backlog debugger
-
getBacklogDebugger
A helper method to return the BacklogDebugger instance if one is enabled- Returns:
- the backlog debugger or null if none can be found
-
getLoggingLevel
-
setLoggingLevel
-
enableDebugger
public void enableDebugger() -
disableDebugger
public void disableDebugger() -
isEnabled
public boolean isEnabled() -
hasBreakpoint
-
isSingleStepMode
public boolean isSingleStepMode() -
attach
public void attach()Attach the debugger which will resume the message processing in case the suspend mode is enabled. Do nothing otherwise. -
detach
public void detach()Detach the debugger which will suspend the message processing in case the suspend mode is enabled. Do nothing otherwise. -
addBreakpoint
-
addConditionalBreakpoint
-
removeBreakpoint
-
removeAllBreakpoints
public void removeAllBreakpoints() -
getBreakpoints
-
resumeBreakpoint
-
setMessageBodyOnBreakpoint
-
setMessageBodyOnBreakpoint
-
removeMessageBodyOnBreakpoint
-
setMessageHeaderOnBreakpoint
public void setMessageHeaderOnBreakpoint(String nodeId, String headerName, Object value) throws org.apache.camel.NoTypeConversionAvailableException - Throws:
org.apache.camel.NoTypeConversionAvailableException
-
setMessageHeaderOnBreakpoint
public void setMessageHeaderOnBreakpoint(String nodeId, String headerName, Object value, Class<?> type) throws org.apache.camel.NoTypeConversionAvailableException - Throws:
org.apache.camel.NoTypeConversionAvailableException
-
getFallbackTimeout
public long getFallbackTimeout() -
setFallbackTimeout
public void setFallbackTimeout(long fallbackTimeout) -
removeMessageHeaderOnBreakpoint
-
resumeAll
public void resumeAll() -
stepBreakpoint
-
step
public void step() -
getSuspendedBreakpointNodeIds
-
getSuspendedExchange
Gets the exchanged suspended at the given breakpoint id or null if there is none at that id.- Parameters:
id
- - node id for the breakpoint- Returns:
- The suspended exchange or null if there isn't one suspended at the given breakpoint.
-
disableBreakpoint
-
enableBreakpoint
-
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
-
getDebugCounter
public long getDebugCounter() -
resetDebugCounter
public void resetDebugCounter() -
beforeProcess
public org.apache.camel.util.StopWatch beforeProcess(org.apache.camel.Exchange exchange, org.apache.camel.Processor processor, org.apache.camel.NamedNode definition) -
afterProcess
public void afterProcess(org.apache.camel.Exchange exchange, org.apache.camel.Processor processor, org.apache.camel.NamedNode definition, long timeTaken) -
doStart
- Overrides:
doStart
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doStop
- Overrides:
doStop
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-