Topics on this page:

Transformer Triggers

Transformer classes support a trigger construct. The term trigger comes from the relational database term describing stored procedure code that executes before or after update, insert, or delete statements. Transformer classes can have triggers at two level: record triggers and transformer triggers.

Record triggers execute before and after each input record is processed. Transformer triggers execute before and after the entire transformation starts and ends.

Record Triggers

Record triggers must implement interface RecordTrigger. Note that RecordTrigger is generic; it's best if it's parameterized when used.

Multiple triggers can be associated with a transformation. Triggers are executed in the order they are provided. Execution method order is as follows:

For each record processed by the transformer:

  • beforeRecordProcessing(T record) is executed on all record triggers in the order they are provided. If any trigger execution excepts, processing of the current record is aborted completely.
  • process(T record) is executed on the transformer
  • If process() produces an exception, afterRecordProcessing(T record, Throwable e) is executed on all record triggers in the order they are provided. All triggers are provided an opportunity for execution in this case, even if they except.
  • If process() executes normally, afterRecordProcessing(T record) is executed on all record triggers in the order they are provided. All triggers are provided an opportunity for execution in this case, even if they except.
  • Transformer Triggers

    Transformer triggers must implement interface TransformerTrigger. Note that TransformerTrigger is generic; it's best if it's parameterized when used.

    A common tactic used for performance when loading large amounts of data is to drop indexes before the load and re-instate them after the load. Transformer triggers can be used for that purpose.

    Multiple triggers can be associated with a transformation. Triggers are executed in the order they are provided. Execution method order is as follows:

    For each record processed by the transformer:

  • init() for the transformer class is executed. If it excepts, no trigger or record processing is attempted. Transformer close() is executed and processing ends.
  • beforeTransformation(Transformer<T> transformer, TransformerContext<T> context) is executed on all transformer triggers in the order they are provided. If any trigger execution excepts, transformer record will not take place. Any trigger that executed beforeTransformation logic will be have afterTransformation executed. However, the runtime state recorded in the context will be TRANSFORM_TRIGGER_BEFORE_ERROR
  • Record processing will be conducted for all records provided by the data source.
  • afterTransformation(Transformer<T> transformer, TransformerContext<T> context) is executed on all transformer triggers in the order they are provided. All transformer triggers after logic will be executed regardless if they except or not. Should after logic on a transformer trigger except, the runtime state in the context will be TRANSFORM_TRIGGER_AFTER_ERROR.
  • close() for the transformer class is executed.