Cert++
Close

Chunk-oriented step callback functions and their lifecycle

Key Takeaway

Optional hooks such as beforeStep and afterStep run only if their attributes (before-step-function, after-step-function) are defined in the step's steptypes.json entry. Unlike read, process and write, the hooks don't fall back to a function with the default name.

A chunk-oriented job step is a custom B2C Commerce job step, written as a CommonJS script module, that works through a list of items in fixed-size batches called chunks. The job framework calls a set of named callback functions in a fixed order. Setup functions run once, read and process run once per item, and write runs once per chunk. Cleanup functions run at the end. The design suits countable data. The design also gives fine-grained progress monitoring, because the count of written items updates after every chunk.

When to use a chunk-oriented step

Choose between a chunk-oriented module and a task-oriented module based on the work the step does.

Chunk-oriented moduleTask-oriented module
FitsCountable data whose boundaries are fixed or quick to calculate, such as exporting a list of ordersA single task whose progress can't be calculated or whose boundaries are hard to calculate
FunctionsA set of named callback functions that the framework calls in a fixed orderOne main function
Exit statusCan't be defined, so the step always finishes with either OK or ERROR.The function can return a dw.system.Status object with a custom code such as FILE_NOT_FOUND.

A chunk-oriented step must be a CommonJS script module. You can't implement one with a pipeline module.

The work isn't limited to database transactions. A chunk-oriented script can include any series of processing steps, such as reading catalog products and writing them to a file in the IMPEX directory.

B2C Commerce Developer Study Guide

Checklist progress

0/237Learned

Prepare for the Exam

Play Today's Certle

Study Community

Ask questions and get the latest info from other B2C Commerce Developer studiers. 796 members and growing.