The Multicast is a component which basically clones your data and send them to all connected target. It has one input and can have two or more outputs.
The Multicast let you send duplicates of your data into each component that you linked to its output.
Note
If you want to split instead of code duplication, you can use Predicates which allow you to let only certain rows pass to a linked destination. See below for further details.
The following code demonstrate a simple example where data would be duplicated and copied into two destinations - a database table and a Json file.
The multicast will create clones of the objects by creating new instances and copying the properties from the input data. Fields, Static values and non public properties will be ignored. If you want to customize how the clone is created, you can implement ICloneable on your object.
The Multicast is useful when you want to broadcast your data to all linked target. If you want to split up your data on the connected target, you don’t need to use the Multicast. You can simple use predicates for this purpose. Predicates allow you to let only certain data pass to a target. This works because you can always link every component to more than one output component. But without Multicast or predicates in place, all message would be send only to the target that was linked first.
Predicates are conditions that describe to which target the data is send if the condition evaluates to true. Let’s modify the example above so that we send the row with the Id 1 or smaller to destination 1 and the row with Id 2 or higher to destination 2.
Make sure when using predicates that always all rows arrive at any kind of destination. Use a VoidDestination for records that you don't want to keep, or use the third parameter of the LinkTo method.