The large XML file arrives through a defined intake channel, for example an SFTP folder, object storage (S3/Blob) with an event trigger, or a message queue. The ingestion service accepts the file, assigns a unique processing id (correlation id) and creates an entry in a status table (“received”). From this point on the file can be traced through the system.
One thing to watch out for with FTP/SFTP as the source, when files are not deleted right after processing: to avoid downloading and processing every file again on each poll, a file should either be moved into a folder such as “processed/” or renamed on the server (where write permissions allow), or — if the files have to stay where they are, untouched — the directory metadata (file name, size, modification date) should be compared against the existing status table before a file is downloaded. The move or rename is best done at the end of stage 1, as soon as parsing and persistence into the database have completed successfully — not only after the processing logic and XML generation, because those are separate, decoupled process chains that only read from the database anyway and no longer need the source file from that point on. The directory listing itself is cheap; only downloading and processing again is expensive. A watermark (the modification date of the last successfully processed file) helps to keep the comparison set small, a claim mechanism helps when several ingestion workers run in parallel, and idempotent persistence acts as a backstop against accidental double processing.
Ingestion (intake)