Search code examples
apache-camel

Replacement for removed newExchange() in Camel 3.16


I'm finally in the process of upgrading our old Camel 2.x stack. WireTapDefinition.newExchange(Processor processor) was removed in 3.16 and I haven't found any examples of how to replace it. What should I replace it with in this instance?

exceptionErrorHandlers.forEach {
  onException(it.exceptionToHandle)
    .process(MyErrorProcessor())
    .wireTap(someUri)
    .newExchange(MyProcessor())
    .end()
    .handled(true)
    .bean(failedCounter, "inc()")
}

Solution

  • I ended up doing this (as mentioned by @ChinHuang in the comments), which seems to work:

    exceptionErrorHandlers.forEach {
      onException(it.exceptionToHandle)
        .process(MyErrorProcessor())
        .wireTap(someUri).copy()
        .onPrepare(MyProcessor())
        .end()
        .handled(true)
        .bean(failedCounter, "inc()")
    }
    

    It's described in the Camel 3.16 upgrade guide, albeit somewhat unclearly:

    Removed the new message mode as this functionality is better done by using onPrepare processor in copy mode