5.2.4.6.1. Error Handling for Messaging Which Uses Database as Queue

5.2.4.6.1.1. Exclude error data and continue processing

The exclusion of error data is done by the callback method (transactionFailure) when an exception occurs.

Important

If the error data is not excluded, the data containing errors gets extracted again and exceptions reoccur. (basically, the result will be the same for the same data processed with the same conditions.) The error data is repeatedly processed if it is not excluded and other data is not processed causing failures (delay failure for example).

An implementation example is shown below.

@Override
protected void transactionFailure(SqlRow inputData, ExecutionContext context) {
  // Since inputData is the data that is input when an error occurrs,
  // Using this information, the corresponding record is updated to a non-processing target
  // (for example, a processing failure status, etc.).
}

5.2.4.6.1.2. Terminate the process abnormally

To terminate the process abnormally, throws ProcessAbnormalEnd.

Important

Since the monitoring process of the table queue is terminated when the process is abnormally terminated, it causes unprocessed data to pile on, delaying capture of data. Continuation of the process using exclude error data is recommended to avoid this problem instead of terminating the process abnormally.

An implementation example is shown below.

@Override
public Result handle(SqlRow inputData, ExecutionContext ctx) {

  if (isAbnormalEnd(inputData)) {
    // In the case of abnormal termination, throws ProcessAbnormalEnd.
    throw new ProcessAbnormalEnd(100, "sample_process_failure");
  }

  return new Result.Success();
}