You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Erik Bakker <ea...@gmx.net> on 2012/02/06 10:24:59 UTC

useOriginalMessage, but not when after splitter

Hi,

I'm setting up a route where a file is parsed in a few steps, then splitter and for each split part, some code is run. 

Now, if somewhere along the parsing steps an exception occurs, I want the original file sent to an alternative endpoint. This is easy with useOriginalMessage.

When an exception occurs after splitting however, I'd like to put just that part into the alternative endpoint, with a filename similar to originalfile_splitindex.

This is where it gets hairy though. When I use useOriginalMessage, what gets delivered to the alternative endpoint is the split-result (so not really the original message, but it is incidentally exactly what I want). However, the headers and attachments of the original message are used, so I have no way to set, for example the CamelFileName header to include the split index. 

So I guess that I need to setup a second exception clause, but I have no idea on how to differentiate between exceptions that occur inside the split and exceptions that occur outside the split. Any ideas? Or am I doing something silly altogether?

I use the Scala DSL, and it looks similar to:

  handle[Exception](-->("file://failures")).useOriginalMessage.handled
	
  "Incoming Files" :: "file://incoming" ==> {
    process (MyFileComponents.parser)
    split   (MyFileComponents.fileSplitter) {
      setHeader("CamelFileName", "test") // <-- This does nothing
      process (ex => {
        throw new Exception("Break!")
      })
    }
  }

Thanks,

Erik

I