Package org.apache.camel.spi
Interface BacklogDebugger
- All Superinterfaces:
AutoCloseable
,Service
,ShutdownableService
,StatefulService
,SuspendableService
A
.
This implementation allows setting breakpoints (with or without a condition) and inspect the
Debugger
that has easy debugging functionality which can be used from JMX with
invalid reference
org.apache.camel.api.management.mbean.ManagedBacklogDebuggerMBean
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
Special breakpoint id token to automatically add breakpoint for every route.static final String
The name of the OS 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. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addBreakpoint
(String nodeId) Adds a breakpoint for the given nodevoid
addConditionalBreakpoint
(String nodeId, String language, String predicate) Adds a conditional breakpoint for the given nodevoid
afterProcess
(Exchange exchange, Processor processor, NamedNode definition, long timeTaken) Callback invoked after a breakpointvoid
attach()
Attach the debugger which will resume the message processing in case the suspend mode is enabled.org.apache.camel.util.StopWatch
beforeProcess
(Exchange exchange, Processor processor, NamedNode definition) Callback invoked before hitting a breakpointvoid
detach()
Detach the debugger which will suspend the message processing in case the suspend mode is enabled.void
disableBreakpoint
(String nodeId) Disables a breakpointvoid
To disable the debuggerdumpTracedMessagesAsJSon
(String nodeId) To dump the debugged messages from the give node id in JSon format.dumpTracedMessagesAsXml
(String nodeId) To dump the debugged messages from the give node id in XML format.void
enableBreakpoint
(String nodeId) Enables a breakpointvoid
To enable the debuggerint
To limit the message body to a maximum size in the traced message.Gets all the breakpoint (node ids)long
Number of breakpoint that has been hitlong
Fallback Timeout in seconds (300 seconds as default) when block the message processing in Camel.Allows to pre-configure breakpoints (node ids) to use with debugger on startup.The debugger logging level to use when logging activity.Gets the trace event for the suspended exchange at the given breakpoint id or null if there is none at that id.Gets node ids for all current suspended exchanges at breakpointsGets the exchanged suspended at the given breakpoint id or null if there is none at that id.boolean
hasBreakpoint
(String nodeId) Does the node have a breakpointboolean
Whether to include the message body of file based messages.boolean
Whether to include the message body of stream based messages.boolean
Whether the debugger is enabledboolean
Trace messages to include exception if the message failedboolean
Whether to include the exchange properties in the traced messageboolean
Whether to include the exchange variables in the traced messageboolean
In single step mode, then when the exchange is created and completed, then simulate a breakpoint at start and end, that allows to suspend and watch the incoming/complete exchange at the route (you can see message body as response, failed exception etc).boolean
Is the debugger currently in single step modeboolean
Whether the debugger is standby.boolean
Whether the debugger should suspend on startup, and wait for a remote debugger to attach.void
Remove all breakpointsvoid
removeBreakpoint
(String nodeId) Removes the breakpointvoid
removeExchangePropertyOnBreakpoint
(String nodeId, String exchangePropertyName) Removes the exchange property at the given breakpointvoid
removeExchangeVariableOnBreakpoint
(String nodeId, String variableName) Removes the variable on the suspended breakpoint at the given node idvoid
removeMessageBodyOnBreakpoint
(String nodeId) Removes the message body (set as null) at the given breakpointvoid
removeMessageHeaderOnBreakpoint
(String nodeId, String headerName) Removes the message header at the given breakpointvoid
Rests the debug countervoid
To resume all suspended breakpoints.void
resumeBreakpoint
(String nodeId) Resume the breakpointvoid
resumeBreakpoint
(String nodeId, boolean stepMode) Resume the breakpoint in step modevoid
setBodyIncludeFiles
(boolean bodyIncludeFiles) Whether to include the message body of file based messages.void
setBodyIncludeStreams
(boolean bodyIncludeStreams) Whether to include the message body of stream based messages.void
setBodyMaxChars
(int bodyMaxChars) To limit the message body to a maximum size in the traced message.void
setExchangePropertyOnBreakpoint
(String nodeId, String exchangePropertyName, Object value) Sets the exchange property at the given breakpointvoid
setExchangePropertyOnBreakpoint
(String nodeId, String exchangePropertyName, Object value, Class<?> type) Updates the exchange property at the given breakpointvoid
setExchangeVariableOnBreakpoint
(String nodeId, String variableName, Object value) Updates/adds the variable (uses same type as old variableName value) on the suspended breakpoint at the given node idvoid
setExchangeVariableOnBreakpoint
(String nodeId, String variableName, Object value, Class<?> type) Updates/adds the variable (with a new type) on the suspended breakpoint at the given node idvoid
setFallbackTimeout
(long fallbackTimeout) Fallback Timeout in seconds (300 seconds as default) when block the message processing in Camel.void
setIncludeException
(boolean includeException) Trace messages to include exception if the message failedvoid
setIncludeExchangeProperties
(boolean includeExchangeProperties) Whether to include the exchange properties in the traced messagevoid
setIncludeExchangeVariables
(boolean includeExchangeVariables) Whether to include the exchange variables in the traced messagevoid
setInitialBreakpoints
(String initialBreakpoints) Allows to pre-configure breakpoints (node ids) to use with debugger on startup.void
setLoggingLevel
(String level) The debugger logging level to use when logging activity.void
setMessageBodyOnBreakpoint
(String nodeId, Object body) Updates the message body at the given breakpointvoid
setMessageBodyOnBreakpoint
(String nodeId, Object body, Class<?> type) Updates the message body at the given breakpointvoid
setMessageHeaderOnBreakpoint
(String nodeId, String headerName, Object value) Sets the message header at the given breakpointvoid
setMessageHeaderOnBreakpoint
(String nodeId, String headerName, Object value, Class<?> type) Sets the message header at the given breakpointvoid
setSingleStepIncludeStartEnd
(boolean singleStepIncludeStartEnd) In single step mode, then when the exchange is created and completed, then simulate a breakpoint at start and end, that allows to suspend and watch the incoming/complete exchange at the route (you can see message body as response, failed exception etc).void
setStandby
(boolean standby) Whether the debugger is standby.void
setSuspendMode
(boolean suspendMode) Whether the debugger should suspend on startup, and wait for a remote debugger to attach.void
step()
To step to next node when in single step mode.void
To start single step mode from the current suspended breakpoint.void
stepBreakpoint
(String nodeId) To start single step mode from a suspended breakpoint at the given node.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 OS 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:
-
BREAKPOINT_ALL_ROUTES
Special breakpoint id token to automatically add breakpoint for every route.- See Also:
-
-
Method Details
-
getInitialBreakpoints
String getInitialBreakpoints()Allows to pre-configure breakpoints (node ids) to use with debugger on startup. Multiple ids can be separated by comma. Use special value _all_routes_ to add a breakpoint for the first node for every route, in other words this makes it easy to debug from the beginning of every route without knowing the exact node ids. -
setInitialBreakpoints
Allows to pre-configure breakpoints (node ids) to use with debugger on startup. Multiple ids can be separated by comma. Use special value _all_routes_ to add a breakpoint for the first node for every route, in other words this makes it easy to debug from the beginning of every route without knowing the exact node ids. -
getLoggingLevel
String getLoggingLevel()The debugger logging level to use when logging activity. -
setLoggingLevel
The debugger logging level to use when logging activity. -
enableDebugger
void enableDebugger()To enable the debugger -
disableDebugger
void disableDebugger()To disable the debugger -
isEnabled
boolean isEnabled()Whether the debugger is enabled -
isStandby
boolean isStandby()Whether the debugger is standby.If a debugger is in standby then the tracer is activated during startup and are ready to be enabled manually via JMX or calling the enableDebugger method.
-
setStandby
void setStandby(boolean standby) Whether the debugger is standby.If a debugger is in standby then the tracer is activated during startup and are ready to be enabled manually via JMX or calling the enableDebugger method.
-
hasBreakpoint
Does the node have a breakpoint -
setSuspendMode
void setSuspendMode(boolean suspendMode) Whether the debugger should suspend on startup, and wait for a remote debugger to attach. This is what the IDEA and VSCode tooling is using. -
isSuspendMode
boolean isSuspendMode()Whether the debugger should suspend on startup, and wait for a remote debugger to attach. This is what the IDEA and VSCode tooling is using. -
isSingleStepMode
boolean isSingleStepMode()Is the debugger currently in single step mode -
attach
void attach()Attach the debugger which will resume the message processing in case the suspend mode is enabled. Do nothing otherwise. -
detach
void detach()Detach the debugger which will suspend the message processing in case the suspend mode is enabled. Do nothing otherwise. -
addBreakpoint
Adds a breakpoint for the given node -
addConditionalBreakpoint
Adds a conditional breakpoint for the given node -
removeBreakpoint
Removes the breakpoint -
removeAllBreakpoints
void removeAllBreakpoints()Remove all breakpoints -
getBreakpoints
Gets all the breakpoint (node ids) -
resumeBreakpoint
Resume the breakpoint -
resumeBreakpoint
Resume the breakpoint in step mode -
setMessageBodyOnBreakpoint
Updates the message body at the given breakpoint -
setMessageBodyOnBreakpoint
Updates the message body at the given breakpoint -
removeMessageBodyOnBreakpoint
Removes the message body (set as null) at the given breakpoint -
setMessageHeaderOnBreakpoint
void setMessageHeaderOnBreakpoint(String nodeId, String headerName, Object value) throws NoTypeConversionAvailableException Sets the message header at the given breakpoint -
setMessageHeaderOnBreakpoint
void setMessageHeaderOnBreakpoint(String nodeId, String headerName, Object value, Class<?> type) throws NoTypeConversionAvailableException Sets the message header at the given breakpoint -
setExchangePropertyOnBreakpoint
void setExchangePropertyOnBreakpoint(String nodeId, String exchangePropertyName, Object value) throws NoTypeConversionAvailableException Sets the exchange property at the given breakpoint -
setExchangePropertyOnBreakpoint
void setExchangePropertyOnBreakpoint(String nodeId, String exchangePropertyName, Object value, Class<?> type) throws NoTypeConversionAvailableException Updates the exchange property at the given breakpoint -
removeMessageHeaderOnBreakpoint
Removes the message header at the given breakpoint -
removeExchangePropertyOnBreakpoint
Removes the exchange property at the given breakpoint -
setExchangeVariableOnBreakpoint
void setExchangeVariableOnBreakpoint(String nodeId, String variableName, Object value) throws NoTypeConversionAvailableException Updates/adds the variable (uses same type as old variableName value) on the suspended breakpoint at the given node id -
setExchangeVariableOnBreakpoint
void setExchangeVariableOnBreakpoint(String nodeId, String variableName, Object value, Class<?> type) throws NoTypeConversionAvailableException Updates/adds the variable (with a new type) on the suspended breakpoint at the given node id -
removeExchangeVariableOnBreakpoint
Removes the variable on the suspended breakpoint at the given node id -
getFallbackTimeout
long getFallbackTimeout()Fallback Timeout in seconds (300 seconds as default) when block the message processing in Camel. A timeout used for waiting for a message to arrive at a given breakpoint. -
setFallbackTimeout
void setFallbackTimeout(long fallbackTimeout) Fallback Timeout in seconds (300 seconds as default) when block the message processing in Camel. A timeout used for waiting for a message to arrive at a given breakpoint. -
resumeAll
void resumeAll()To resume all suspended breakpoints. -
stepBreakpoint
To start single step mode from a suspended breakpoint at the given node. Then invokestep()
to step to next node in the route. -
stepBreakpoint
void stepBreakpoint()To start single step mode from the current suspended breakpoint. Then invokestep()
to step to next node in the route. -
step
void step()To step to next node when in single step mode. -
getSuspendedBreakpointNodeIds
Gets node ids for all current suspended exchanges at breakpoints -
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.
-
getSuspendedBreakpointMessage
Gets the trace event for the suspended exchange at the given breakpoint id or null if there is none at that id.- Parameters:
id
- node id for the breakpoint- Returns:
- the trace event or null if there isn't one suspended at the given breakpoint.
-
disableBreakpoint
Disables a breakpoint -
enableBreakpoint
Enables a breakpoint -
setSingleStepIncludeStartEnd
void setSingleStepIncludeStartEnd(boolean singleStepIncludeStartEnd) In single step mode, then when the exchange is created and completed, then simulate a breakpoint at start and end, that allows to suspend and watch the incoming/complete exchange at the route (you can see message body as response, failed exception etc). -
isSingleStepIncludeStartEnd
boolean isSingleStepIncludeStartEnd()In single step mode, then when the exchange is created and completed, then simulate a breakpoint at start and end, that allows to suspend and watch the incoming/complete exchange at the route (you can see message body as response, failed exception etc). -
getBodyMaxChars
int getBodyMaxChars()To limit the message body to a maximum size in the traced message. Use 0 or negative value to use unlimited size. -
setBodyMaxChars
void setBodyMaxChars(int bodyMaxChars) To limit the message body to a maximum size in the traced message. Use 0 or negative value to use unlimited size. -
isBodyIncludeStreams
boolean isBodyIncludeStreams()Whether to include the message body of stream based messages. If enabled then beware the stream may not be re-readable later. See more about Stream Caching. -
setBodyIncludeStreams
void setBodyIncludeStreams(boolean bodyIncludeStreams) Whether to include the message body of stream based messages. If enabled then beware the stream may not be re-readable later. See more about Stream Caching. -
isBodyIncludeFiles
boolean isBodyIncludeFiles()Whether to include the message body of file based messages. The overhead is that the file content has to be read from the file. -
setBodyIncludeFiles
void setBodyIncludeFiles(boolean bodyIncludeFiles) Whether to include the message body of file based messages. The overhead is that the file content has to be read from the file. -
isIncludeExchangeProperties
boolean isIncludeExchangeProperties()Whether to include the exchange properties in the traced message -
setIncludeExchangeProperties
void setIncludeExchangeProperties(boolean includeExchangeProperties) Whether to include the exchange properties in the traced message -
isIncludeExchangeVariables
boolean isIncludeExchangeVariables()Whether to include the exchange variables in the traced message -
setIncludeExchangeVariables
void setIncludeExchangeVariables(boolean includeExchangeVariables) Whether to include the exchange variables in the traced message -
isIncludeException
boolean isIncludeException()Trace messages to include exception if the message failed -
setIncludeException
void setIncludeException(boolean includeException) Trace messages to include exception if the message failed -
dumpTracedMessagesAsXml
To dump the debugged messages from the give node id in XML format. -
dumpTracedMessagesAsJSon
To dump the debugged messages from the give node id in JSon format. -
getDebugCounter
long getDebugCounter()Number of breakpoint that has been hit -
resetDebugCounter
void resetDebugCounter()Rests the debug counter -
beforeProcess
org.apache.camel.util.StopWatch beforeProcess(Exchange exchange, Processor processor, NamedNode definition) Callback invoked before hitting a breakpoint -
afterProcess
Callback invoked after a breakpoint
-