I am new to Spring Integration and have an application that accepts files as input and does some specific processing on those files depending on the contents of each file.
When the file comes in, I have a router that decides whether is type "A", "B" or a "ZIP" file and routes it to the appropriate channel. In the case of a ZIP file I have a splitter which unzips the zip file and sends the results back to the router to determine which type of file from the zip is - A, B, or a nested ZIP file.
There is also an error-channel specified that handles file parsing errors.
The relevant part of the XML looks something like this:
<?xml version="1.0" encoding="UTF-8"?>
...
...
<int:channel id="checkFile" />
<int:channel id="A" />
<int:channel id="B" />
<int:channel id="ZIP" />
<!-- Route the file to the appropriate parser - A, B, or ZIP -->
<int:router input-channel="checkFile" ref="fileTypeIdentifier" method="identifyType" />
<!-- If we have a ZIP file, extract the contents and process each one individually -->
<int:splitter input-channel="ZIP" output-channel="checkFile" ref="extractor" />
<!-- Parse file type A -->
<int:chain input-channel="A" output-channel="Done">
...
...
</int:chain>
<!-- Parse file type B -->
<int:chain input-channel="B" output-channel="Done">
...
...
</int:chain>
...
...
If my input file is myfile.zip which contains file1.txt and file2.txt, the router correctly routes myfile.zip to the splitter which successfully extracts file1.txt and file2.txt (and returns those 2 files).
If I have an error parsing file1.txt I would still like to try to parse file2.txt. So after reading Spring Integration: Splitter exception causes subsequent messages to abort I tried making my "checkFile" channel a queue channel, now what happens is I pass in myfile.zip which gets routed to the "ZIP" channel, which successfully returns "file1.txt" and "file2.txt", but then the router keeps getting called with "myfile.zip" in an endless loop.
A similar problem results from using an executor channel instead of a queue channel.
How can I get my flow to unzip files and process their contents individually, while allowing one or more of the files inside the zip to fail without failing the entire job?
extractor
doesn't return the original file it can't go to thecheckFile
. For example you don't show a<poller>
configuration. – Artem Bilan