Interface BacklogTracer

All Known Subinterfaces:
SyntheticBacklogTracer

public interface BacklogTracer
Passive message capture mechanism that records a rolling window of the last N exchange snapshots as they pass through route nodes, as described in the Backlog Tracer documentation.

Unlike the Debugger/BacklogDebugger which can suspend and step through exchanges, the BacklogTracer is non-blocking: it takes a snapshot of each exchange at each route node and adds it to a bounded circular queue (the "backlog"). Snapshots are available via

invalid reference
#dumpTracedMessagesAsXml(String, boolean)
or
invalid reference
#dumpTracedMessagesAsJSon(String, boolean)
for inspection or test assertions. The maximum number of messages held in the backlog is configured by setBacklogSize(int).

The tracer can be filtered to a subset of routes and nodes via setTraceFilter(String), and can be put in standby mode (activated but not collecting) so it can be toggled at runtime via JMX without restarting Camel.

Since:
4.0
See Also:
  • Method Details

    • isEnabled

      boolean isEnabled()
      Is the tracer enabled.
    • setEnabled

      void setEnabled(boolean enabled)
      To turn on or off the tracer
    • isStandby

      boolean isStandby()
      Whether the tracer is standby.

      If a tracer is in standby then the tracer is activated during startup and are ready to be enabled manually via JMX or calling the enabled method.

    • setStandby

      void setStandby(boolean standby)
      Whether the tracer is standby.

      If a tracer is in standby then the tracer is activated during startup and are ready to be enabled manually via JMX or calling the enabled method.

    • getBacklogSize

      int getBacklogSize()
      Number of messages to keep in the backlog. Default is 100.
    • setBacklogSize

      void setBacklogSize(int backlogSize)
      Number of messages to keep in the backlog (should be between 1 - 1000). Default is 100.
    • isRemoveOnDump

      boolean isRemoveOnDump()
      Remove the currently traced messages when dump methods are invoked
    • setRemoveOnDump

      void setRemoveOnDump(boolean removeOnDump)
      Remove the currently traced messages when dump methods are invoked
    • getBodyMaxChars

      int getBodyMaxChars()
      Maximum number of bytes to keep for the message body (to prevent storing very big payloads)
    • setBodyMaxChars

      void setBodyMaxChars(int bodyMaxChars)
      Maximum number of bytes to keep for the message body (to prevent storing very big payloads)
    • isBodyIncludeStreams

      boolean isBodyIncludeStreams()
      Trace messages to include message body from streams
    • setBodyIncludeStreams

      void setBodyIncludeStreams(boolean bodyIncludeStreams)
      Trace messages to include message body from streams
    • isBodyIncludeFiles

      boolean isBodyIncludeFiles()
      Trace messages to include message body from files
    • setBodyIncludeFiles

      void setBodyIncludeFiles(boolean bodyIncludeFiles)
      Trace messages to include message body from files
    • isIncludeExchangeProperties

      boolean isIncludeExchangeProperties()
      Trace messages to include exchange properties
    • setIncludeExchangeProperties

      void setIncludeExchangeProperties(boolean includeExchangeProperties)
      Trace messages to include exchange properties
    • isIncludeExchangeVariables

      boolean isIncludeExchangeVariables()
      Trace messages to include exchange variables
    • setIncludeExchangeVariables

      void setIncludeExchangeVariables(boolean includeExchangeVariables)
      Trace messages to include exchange variables
    • 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
    • isTraceRests

      boolean isTraceRests()
      Whether to support tracing messages and outputting as JSon.
    • setTraceRests

      void setTraceRests(boolean traceRests)
      Whether to trace routes that is created from route templates or kamelets.
    • isTraceTemplates

      boolean isTraceTemplates()
      Whether to trace routes that is created from route templates or kamelets.
    • setTraceTemplates

      void setTraceTemplates(boolean traceTemplates)
      Whether to trace routes that is created from route templates or kamelets.
    • getTracePattern

      @Nullable String getTracePattern()
      Filter for tracing by route or node id
    • setTracePattern

      void setTracePattern(@Nullable String tracePattern)
      Filter for tracing by route or node id
    • getTraceFilter

      @Nullable String getTraceFilter()
      Filter for tracing messages
    • setTraceFilter

      void setTraceFilter(@Nullable String filter)
      Filter for tracing messages
    • getTraceCounter

      long getTraceCounter()
      Gets the trace counter (total number of traced messages)
    • incrementTraceCounter

      long incrementTraceCounter()
      Increments and returns the trace counter.
      Since:
      4.21
    • getQueueSize

      long getQueueSize()
      Number of traced messages in the backlog
    • resetTraceCounter

      void resetTraceCounter()
      Reset the tracing counter
    • shouldTrace

      boolean shouldTrace(NamedNode node, Exchange exchange)
      Whether the tracer should trace the given node and exchange (taking into account patterns and filters).
      Since:
      4.21
    • traceEvent

      void traceEvent(BacklogTracerEventMessage event)
      Records a trace event. Used internally by the route pipeline advices to submit pre-built trace events.
      Since:
      4.21
    • getAllTracedMessages

      Collection<BacklogTracerEventMessage> getAllTracedMessages()
      Get all tracing data (without removing)
    • getLatestMessageHistory

      Collection<BacklogTracerEventMessage> getLatestMessageHistory()
      Get latest completed exchange message history (without removing)
    • dumpAllTracedMessages

      List<BacklogTracerEventMessage> dumpAllTracedMessages()
      Dumps all tracing data
    • dumpLatestMessageHistory

      List<BacklogTracerEventMessage> dumpLatestMessageHistory()
      Dumps latest completed exchange message history
    • dumpTracedMessages

      List<BacklogTracerEventMessage> dumpTracedMessages(String nodeId)
      Dumps tracing data for the given route id / node id
    • dumpAllTracedMessagesAsXml

      String dumpAllTracedMessagesAsXml()
      Dumps all tracing data as XML
    • dumpTracedMessagesAsXml

      String dumpTracedMessagesAsXml(String nodeId)
      Dumps tracing data for the given route id / node id as XML
    • dumpLatestMessageHistoryAsXml

      String dumpLatestMessageHistoryAsXml()
      Dumps latest completed exchange message history as XML
    • dumpAllTracedMessagesAsJSon

      String dumpAllTracedMessagesAsJSon()
      Dumps all tracing data as JSon
    • dumpTracedMessagesAsJSon

      String dumpTracedMessagesAsJSon(String nodeId)
      Dumps tracing data for the given route id / node id as JSon
    • dumpLatestMessageHistoryAsJSon

      String dumpLatestMessageHistoryAsJSon()
      Dumps latest completed exchange message history as JSon
    • clear

      void clear()
      Clears the backlog of traced messages.