Configuration.replaceMessageBody()
Description
Appends a replaceMessageBody filter to the current pipeline layout.
A replaceMessageBody filter calls back user scripts to get a replacement for each complete message body (Data) found in the input stream.
- INPUT - Any types of Events.
- OUTPUT - Any types of Events.
The user function will receive as parameter a Data object that contains a full message body and is removed from the input stream. Whatever the function returns will be inserted into the output stream in place of the removed events. It can be an event or a Message, or an array of events or Messages. If the function returns nothing (null or undefined), no events will be inserted back into the stream.
This filter only calls the user function once for each message in the input stream. If the message's body is composed of multiple Data events, replaceMessageBody will wait until all Data objects composing the whole message are collected and call the user function with a combined Data event.
You can also use a fixed replacement value instead of a function if the replacement is static.
Syntax
pipy().pipeline().replaceMessageBody(data => transform(data))
Parameters
replaceMessageBody(handler?)
A callback function that receives message bodies passing through the filter and returns their replacements. The replacement can be an Event, a Message or an array of them.
The same Configuration object.