Skip to content

Processors as outputs

It might be the case that a processor that results in a side effect, such as the sql_insert or redis processors, is the only side effect of a pipeline, and therefore could be considered the output.

In such cases it’s possible to place these processors within a reject output so that they behave the same as regular outputs, where success results in dropping the message with an acknowledgement and failure results in a nack (or retry):

output:
reject: 'failed to send data: ${! error() }'
processors:
- try:
- redis:
url: tcp://localhost:6379
command: sadd
args_mapping: 'root = [ this.key, this.value ]'
- mapping: root = deleted()

The way this works is that if your processor with the side effect (redis in this case) succeeds then the final mapping processor deletes the message which results in an acknowledgement. If the processor fails then the try block exits early without executing the mapping processor and instead the message is routed to the reject output, which nacks the message with an error message containing the error obtained from the redis processor.