File ingestion pull and segment processing
What it does. Two jobs move partner files into Finance and Operations. Run file ingestion (the pull) picks up new files from every enabled file ingestion connection and splits each file into one segment per record. Process file ingestion segments (the segment processor) transforms each queued segment and sends it to the connection's target service operation. Runs: when you schedule each of them as a batch job, once for the whole environment. Who looks after it: Integration administrator.
Purpose
A file ingestion connection only describes where files arrive and what to do with them. Nothing reads a file until the pull runs, and nothing posts a record until the segment processor runs. Without the pull, files pile up in the source folder; without the segment processor, every record stays Queued on the File ingestion monitor and nothing is posted.
The work is split in two so that a file is taken in quickly and in one piece (the file, its bundle and all its segments are committed together, or nothing is), while the slower posting of each record runs, retries and fails record by record.
When it runs
- Only when you schedule it, or run it from its menu item. Neither job is a background process.
- Each job serves every enabled connection. Connections, bundles and segments are shared by all legal entities, so one schedule of each job covers the environment.
- A pull run takes each enabled connection in turn and stops for a connection when its files are done or its Maximum files per run is reached. A segment processor run takes the oldest queued segment that is due, then the next, until none is left, and ends.
- The daily removal of processed bundles is a separate background process, the Lattice file ingestion cleanup. There is nothing to schedule for it.
Configuration and scheduling
The settings that change what the jobs do are on System administration > Setup > Lattice > File ingestion > File ingestion connections, per connection:
| Tab | Field | Default | Effect |
|---|---|---|---|
| Header | Enabled | No | Only enabled connections are pulled |
| Source | Folder path, File pattern | Blank | Which files the pull lists |
| Source | Archive folder path | Blank | Where an ingested file is moved; blank deletes it from the source |
| Source | Error folder path | Blank | Where a file that cannot be ingested is moved; blank leaves it in place, and every run tries it again |
| File format | File format, Record path and the CSV and fixed-width fields | CSV has header Yes | How the pull splits a file into records |
| File format | Decrypt source files (PGP) | No | The pull decrypts each file before reading it |
| Processing | Target service class, Operation, Allowed service operations | Blank | Where the segment processor sends each record |
| Processing | Liquid template | Blank | How each record is transformed; blank sends the record as JSON unchanged |
| Schedule | Minimum file age (seconds) | 0, which means 60 seconds | A file younger than this waits for a later run |
| Schedule | Wait until the file size is stable | No | Yes: a file is taken only when its size is the same as on the previous run |
| Schedule | Maximum files per run | 0, which means no limit | The rest of the files wait for the next run |
| Schedule | Retention (days) | 30 | Used by the cleanup, not by these jobs |
How often each job runs is its batch recurrence. Schedule each job once:
- For the pull, go to File ingestion connections and select Run file ingestion in the Processing group of the action pane. For the segment processor, go to System administration > Periodic tasks > Lattice > Process file ingestion segments.
- Neither dialog has fields of its own. Expand Run in the background, set Batch processing to Yes and enter a Task description (and a Batch group if your environment uses them).
- Select Recurrence and set the interval, then OK:
- The pull: at the pace files arrive. A file is taken no sooner than Minimum file age (seconds) after it was last written, and with Wait until the file size is stable at least one run later, so a very short interval does not make files arrive faster.
- The segment processor: at least as often as the pull. A record that failed is due again 30 seconds after its first failure and 60 seconds after its second, but is retried only by the first run after that.
- Select OK to create the batch job.
Started from its menu item, Process file ingestion segments always runs as a batch job: with Batch processing left at No, selecting OK queues a one-time job that starts as soon as the batch service picks it up. Run file ingestion with Batch processing at No runs once, now, while you wait.
The segment processor's legal entity and user matter. A record whose template leaves
LegalEntityIdempty is posted in the legal entity the segment processor job runs in, and a record without aUserContextcarries the job's user. The operation also runs with that user's permissions. Schedule the job from the legal entity you want as the default, as a user who holds the privileges for the target operations.
How it works
The pull, for each enabled connection:
- Claims the connection for 60 minutes, renewed before each file. When another run holds it, the connection is skipped with "Another pull run is processing this connection. The connection was skipped."
- Lists the files in Folder path that match File pattern.
- Skips a file that is too new or, with Wait until the file size is stable, whose size changed since the previous run. Each skip is logged and the file is taken by a later run.
- Downloads the file once, decrypts it when the connection says so, and skips it when the same path with the same content was already ingested (then archives or deletes it).
- Splits it into records. In one transaction it creates the bundle, stores a copy of the file in document management, creates one segment per record with state Queued, and records the file as ingested. A file that is empty or produces no records is not ingested.
- After the commit, moves the file to Archive folder path, or deletes it.
- A file that fails is logged with "Failed to ingest file '%1'." and moved to Error folder path when there is one.
The segment processor, segment by segment:
- Takes the oldest Queued segment whose retry time has passed. Several runs at once each take different segments.
- Converts an XML record to JSON, renders the connection's Liquid template, and resolves any cross-reference placeholders.
- Sends the result to the target operation. Through the service-invoke target, the operation must be in Allowed service operations and known to the service metadata catalog.
- On success the segment becomes Processed and keeps the Request ID it was sent with.
- On failure the attempt is counted. After the first and second failure the segment stays Queued with a retry time 30 and then 60 seconds ahead. After the third it becomes Failed and is parked in the dead-letter queue for someone to fix and replay. A segment someone put on Held is skipped until it is released.
Before it can run
- At least one connection with Enabled selected and a working secret, and for the segment processor a target (with its Allowed service operations when the target is the service-invoke target).
- The service metadata catalog filled by the service metadata refresh, for connections that route records through the service-invoke target.
- The batch service is running.
- The license does not stop a scheduled run. Started from a menu item while the license blocks Lattice, each job shows a license warning and does nothing.
Inputs and outputs
| Job | Reads | Writes |
|---|---|---|
| Pull | Files in the connection's source; the connection's settings and secret | Bundles, Queued segments, the stored copy of each file, the record of ingested files, the ingestion log; moves or deletes source files |
| Segment processor | Queued segments; the connection's template and target | The segment's state, transformed content, request ID and error; the documents the target operation creates or posts; dead letters for failed records; the ingestion log |
Monitoring and logs
- System administration > Inquiries > Lattice > File ingestion > File ingestion operations: the Active connections and Dead letters awaiting action tiles, and the Recent bundles, Segments, Ingestion log and Dead-letter queue lists.
- System administration > Inquiries > Lattice > File ingestion > File ingestion monitor: each bundle with its segments (State, Processing attempts, Error message) and its Log.
- The ingestion log holds the pull's "File ingestion pull started." and "File ingestion pull completed. %1 connection(s) processed.", one line per file ingested or skipped, and one line per record processed or failed.
- System administration > Inquiries > Batch jobs: the two jobs and their history.
When it fails
The pull isolates each file and each connection: a failure is logged and the run goes on. The segment processor retries each record twice, then parks it.
| Symptom | Cause | Fix |
|---|---|---|
| Files stay in the source folder and nothing is logged | The pull is not scheduled, the connection is not Enabled, or the batch service is stopped | Schedule Run file ingestion and enable the connection |
| "File '%1' was last written %2 seconds ago, less than the minimum file age of %3 seconds. It is picked up by a later run." | The file is newer than Minimum file age (seconds) | Expected: a later run takes it |
| "File '%1' produced no records with record path '%2'. It was not ingested and was left in place. Check the record path and the file format." | Record path or the file format does not match the file | Correct the connection; the file is tried again by the next run unless it was moved to the error folder |
| "The connection's limit of %1 files per run is reached. %2 listed files wait for the next run." | Maximum files per run reached | Expected; raise the limit or run the pull more often |
| "Failed to process connection." | The source could not be reached or listed (secret, endpoint, network) | Use Test connection on the connection and read the details on the log line |
| Segments stay Queued | The segment processor is not scheduled, or every queued segment is waiting for its retry time | Schedule Process file ingestion segments |
| A segment fails with "Dispatch to the target service reported failure." and the log says "Custom service dispatch to %1.%2 failed with a business error." | The target operation refused the record; the log line's details give its message | Fix the data or the template, then replay the dead letter after the third attempt |
| The details read "No metadata found for operation %1.%2. Run the service metadata refresh first." | The service metadata catalog is empty, or a refresh was running | Run the service metadata refresh, then replay the parked records |
| The details read "The routing envelope names %1, which is not in the connection's allowed service operations. Nothing was invoked." | The operation is not in Allowed service operations | Add it on the connection's Processing tab |
| The details read "You do not have access to operation %1.%2. A privilege that grants the service operation is required." | The segment processor job's user lacks the operation's privilege | Give that user the privilege, or schedule the job as another user |
Effect on the rest of Lattice
- Through the service-invoke target, records post through the same Lattice operations as an integration call, with the same idempotency: a record sent again with the same request key replays the first result instead of posting twice.
- While the license blocks Lattice on a production environment, the operations refuse each record, so records fail three times and are parked. Replay them once the license is restored.
- A failed record becomes a dead letter of source file ingestion. The dead-letter retry background process closes it once its segment has been processed after a replay.
- A service metadata refresh empties the catalog before it fills it again. Records sent through the service-invoke target while it runs can fail and use up their attempts, so run the refresh when files are quiet, and check the dead-letter queue afterwards.
- Run file ingestion started while the scheduled pull is working on a connection skips that connection: only one run works on a connection at a time.
Related
- I want to set up a file ingestion connection
- I want to schedule the Lattice jobs that are not background processes
- I want to hold or release one record of an ingested file
- I want to follow a file from arrival to posting
- I want to see what happened to a file I sent
- Scenario: inbound file to posted document
- File ingestion user guide
- File ingestion connections
- Lattice file ingestion cleanup