All posts

Spooldoc 0.8.0: routes send each document by its fields

Routes send each document of a spooled file to a destination by its fields, so one job can email the invoices of customers with an address and write the rest to an IFS folder.

Spooldoc 0.8.0 is out. One job can now send each document of a spooled file its own way. Take an invoice spooled file where some customers have an email address and some do not. A lookup reads the address from Db2 for i, the invoices with one go by email, and the rest go to a folder in the IFS. Before, that took two jobs on two output queues or a program change. Nothing breaks: the upgrade is a pull and a restart, and every job delivers as it did.

What changed

Routes. A job's routes are in its Destination step, in order. Each route has conditions on the fields of the document, and one or more destinations. A document takes the first route whose conditions it all matches, and goes to every destination of that route, such as an email to the customer and a copy in an IFS folder. The last route without conditions reads Otherwise and takes every document the routes above do not. There is no "or": another route does that. Routes has the details.

The Destination step of an invoice job with two routes. The page group stepper shows page group 1 of 6, invoice-260101, and under it the line Page group 1 takes route 1, with Why. Route 1 takes 4 of 6 page groups when pg.customerEmail is not empty, and sends them to the email destination Customer invoices by email. Otherwise takes the other 2 and sends them to the IFS destination Invoice archive, written to /home/docs/invoices.The Destination step of an invoice job with two routes. The page group stepper shows page group 1 of 6, invoice-260101, and under it the line Page group 1 takes route 1, with Why. Route 1 takes 4 of 6 page groups when pg.customerEmail is not empty, and sends them to the email destination Customer invoices by email. Otherwise takes the other 2 and sends them to the IFS destination Invoice archive, written to /home/docs/invoices.

Conditions. A condition reads one field with a single value: a field of the page group such as pg.email, a column a lookup adds such as pg.customer.EMAIL, or a field of the spooled file such as splf.name. It can check that the field is empty, is not empty, equals a value, is one of a list of values, or matches a regular expression such as ^SE-. It compares the value in the data, not the printed text: a number field compares as a number and a date field as a date. Changing the Formats in Settings never sends a document another way.

See where each page group goes. The page group stepper is now at the top of the Destination step. It shows the route of each page group, and under it the step says "Page group 3 takes route 1". Why shows each condition with the value of its field in that page group, and the ones that do not match, such as pg.country is DK, not SE. The email, webhook and SFTP previews follow the stepper. Nothing is sent.

A document that takes no route is never dropped. The run delivers the documents that took a route, then fails. The Route step in the job log lists each document that took none, with why each route did not take it. The spooled file is not held, moved or deleted. Add a route for them, save a version and Retry: only what was not sent goes, since Spooldoc remembers what each destination sent. A document that takes no route has the details.

Retry for IFS files. Retry now writes only the files that an IFS destination has not written yet: "Wrote 1 file to /home/docs/out on ibmi.example.com, 5 were written in run #12". So Add a number never makes a second copy of a file on retry. A run that writes to an IFS folder also has a Files written list in the job log, with the path each file got, its size and its status. Files written and Retry have the details.

All changes are in the release notes.

Upgrading

Take a pg_dump, then pull ghcr.io/strom-capital/spooldoc:0.8.0 and start it. The server applies the new migration. Nothing else needs you.

  • Every job keeps its destination. The migration turns each job's destination, in its draft and in every saved version, into one route with no conditions. Jobs deliver as before, and the Destination step shows the pick of one destination as it did. Add a condition or Add a route below the destinations starts routes.
  • Runs from before this release have no Files written list, though they wrote their files. The Deliver step says what they wrote, and a Retry of one writes every file again.

Tell us

Questions go to Q&A, ideas to Ideas, bugs to the issues. We most want to hear how you split a spooled file: the fields your routes read, and a document that went another way than you expected. Replace real library, host and customer names before you paste it.

The 0.8.0 release is on GitHub, and so is the announcement. Every change is in the changelog.

All changes in 0.8.0 are in the changelog.