Search code examples
javaapache-camelcamel-ftp

No processor found in splitter after validation.


I have a Camel route that needs to receive a XML file from FTP as a stream, validate it and split it.

Everything works fine all the way to the validation, but then the split doesn't work as expected. When debugging, I found the split process doesn't find any processor when the original message is a stream. It looks very much like a bug to me.

     from("direct:start")
    .pollEnrich("ftp://user@host:21?fileName=file.xml&streamDownload=true&password=xxxx&fastExistsCheck=true&soTimeout=300000&disconnect=true")
    .to("validator:myXsd.xsd")
    .split().tokenizeXML("myTag")
    .to(to)
    .end();

In this case I can see the Exchange getting in the splitter, but no processor is found and the split does nothing. the behavior is different if I remove the validation:

     from("direct:start")
    .pollEnrich("ftp://user@host:21?fileName=file.xml&streamDownload=true&password=xxxx&fastExistsCheck=true&soTimeout=300000&disconnect=true")
    .split().tokenizeXML("myTag")
    .to(to)
    .end();

In this case, the splitter works fine.

Also, if the XML file doesn't come from a stream, then everything is fine.

   from("file:file.xml")
    .to("validator:myXsd.xsd")
    .split().tokenizeXML("myTag")
    .to(to)
    .end();

I update my Camel version to 2.15.2 but still get the same error.


Solution

  • The problem that I was trying to pass a body that was a stream. (streamDownload=true). The validator will read the stream and validate the content. No problem.

    But the problem comes when the split arrives, the stream was already read and closed. So the split can't do anything with the stream.

    I already worked around the problem without a stream, but I guess working with streamcaching would also work if a stream is necessary.

    See http://camel.apache.org/why-is-my-message-body-empty.html