Skip to content

Instantly share code, notes, and snippets.

@davsclaus
Created June 4, 2013 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davsclaus/5704618 to your computer and use it in GitHub Desktop.
Save davsclaus/5704618 to your computer and use it in GitHub Desktop.
@Override
public void beforeProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition) {
// store a copy of the message so we can see that from the debugger
Date timestamp = new Date();
String toNode = definition.getId();
String routeId = ProcessorDefinitionHelper.getRouteId(definition);
String exchangeId = exchange.getExchangeId();
String messageAsXml = MessageHelper.dumpAsXml(exchange.getIn(), true, 2, isBodyIncludeStreams(), isBodyIncludeFiles(), getBodyMaxChars());
long uid = debugCounter.incrementAndGet();
BacklogTracerEventMessage msg = new DefaultBacklogTracerEventMessage(uid, timestamp, routeId, toNode, exchangeId, messageAsXml);
suspendedBreakpointMessages.put(toNode, msg);
// suspend at this breakpoint
SuspendedExchange se = new SuspendedExchange(exchange, new CountDownLatch(1));
suspendedBreakpoints.put(toNode, se);
// now wait until we should continue
logger.log("StepBreakpoint at node " + toNode + " is waiting to continue for exchangeId: " + exchange.getExchangeId());
try {
boolean hit = se.getLatch().await(fallbackTimeout, TimeUnit.SECONDS);
if (!hit) {
logger.log("StepBreakpoint at node " + toNode + " timed out and is continued exchangeId: " + exchange.getExchangeId(), LoggingLevel.WARN);
} else {
logger.log("StepBreakpoint at node " + toNode + " is continued exchangeId: " + exchange.getExchangeId());
}
} catch (InterruptedException e) {
// ignore
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment