Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-4246

TraceInterceptor does not work correctly for AsyncProcessing

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.7.1
    • 2.8.1, 2.9.0
    • camel-core
    • None

    Description

      TraceEventHandlers are not called correctly when a node is processed asynchronously.

      From org.apache.camel.processor.interceptor.TraceInterceptor:
      try {
      // special for interceptor where we need to keep booking how far we have routed in the intercepted processors
      if (node.getParent() instanceof InterceptDefinition && exchange.getUnitOfWork() != null)

      { TracedRouteNodes traced = exchange.getUnitOfWork().getTracedRouteNodes(); traceIntercept((InterceptDefinition) node.getParent(), traced, exchange); }

      // process the exchange
      try

      { sync = super.process(exchange, callback); }

      catch (Throwable e)

      { exchange.setException(e); }

      } finally {
      // after (trace out)
      if (shouldLog && tracer.isTraceOutExchanges())

      { logExchange(exchange); traceExchangeOut(exchange, traceState); }

      }

      As it is this results in traceExchangeOut being called before the callback, which is wrong.
      The call to super.process needs to wrap the callback to call traceExchangeOut (and the finally block shouldn't run if the process is asynch).

      This isn't a regression, but the change to make more routes asynchronous makes it more noticeable.

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            yaytay Yaytay
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: