nullPainter
nullPainter

Reputation: 3056

Apache Camel SEDA exception handling

Using Apache Camel, I need to perform XSD validation on XML files contained within zip files, with any exceptions resulting in the zip file being shifted to an error folder.

The following (simplified) route works well*:

from("file:/my/Path&moveFailed=../error").split(new ZipSplitter()).
    streaming().filter(header(Exchange.FILE_NAME).endsWith(".xml")).
        bean(MyCustomValidator.class).to("validator:schemas/my/schema.xsd").end();

In order to improve efficiency, I have tweaked it to use SEDA for the zip content checks:

from("file:/my/Path&moveFailed=../error").split(new ZipSplitter()).
    streaming().filter(header(Exchange.FILE_NAME).endsWith(".xml")).
        to("seda:validateEvents");

from("seda:validateEvents?concurrentConsumers=20").bean(MyValidator.class).
    to("validator:schemas/my/schema.xsd").end();

However, now the moveFailed parameter isn't being honoured from the file component. If I add an explicit onException() and attempt to copy files into the error folder, any XSD validation failures copies the XML files - not the zip file - into the error folder.

How can I perform parallel processing of a component while maintaining error handling for the endpoint?

*I've used an explicit file name filter for the zip file contents, otherwise the splitter executes my bean validator once for each XML file in the zip, and once more for the zip file itself (?!).

Upvotes: 1

Views: 1187

Answers (1)

Claus Ibsen
Claus Ibsen

Reputation: 55540

See the shareUnitOfWork option at

And insted of using SEDA you can just use parallel processing in the splitter.

Upvotes: 1

Related Questions