Task-oriented versus chunk-oriented custom job step modules
Key Takeaway
Use a task-oriented module for one task with no clear progress measure, and a chunk-oriented module for a countable set of items. Only a task-oriented step can set its own exit status, by returning a dw.system.Status that can carry a custom status code. A chunk-oriented step always finishes with either OK or ERROR.
A custom job step lets a scheduled B2C Commerce job run your own code when no system step does what you need. You write that code as a CommonJS script module in one of two styles. In a task-oriented module, the job framework calls one main function. In a chunk-oriented module, the framework reads, processes, and writes a list of items in fixed-size batches. The right style depends on whether the work is one task with no clear progress measure or a countable set of items.
Task-oriented and chunk-oriented modules
Both styles are CommonJS script modules. They differ in how the job framework calls your code, so each style fits a different kind of work.
| Task-oriented | Chunk-oriented | |
|---|---|---|
| How it runs | Exposes one function, which the framework calls as the step's main function | Reads, processes, and writes items in chunks of a defined size |
| Works best for | A single task where progress can't be calculated or the boundaries are hard to calculate | Countable data where the boundaries can be quickly calculated or are fixed |
| Example | Connecting to an FTP server and downloading a file | Exporting a list of orders or products to a file |
A chunk can run any series of processing steps, not just database transactions.
Chunk-oriented steps can't be built with a pipeline module. Pipeline modules are legacy and should be migrated to CommonJS script modules.