3

So I have this requirement, that takes in one document, and from that needs to create one or more documents in the output.

During the cause of this, it needs to determine if the document is already there, because there are different operations to apply for create and update scenarios.

In straight code, this would be simple (conceptually)

InputData in = <something>

if (getItemFromExternalSystem(in.key1) == null) {
     createItemSpecificToKey1InExternalSystem(in.key1);
}
if (getItemFromExternalSystem(in.key2) == null) {
     createItemSpecificToKey2InExternalSystem(in.key1, in.key2);
}
createItemFromInput(in.key1,in.key2, in.moreData);

In effect a kind of "ensure this data is present".

However, in IIB How would i go about achieving this? If i used a subflow for the Get/create cycle, the output of the subflow would be whatever the result of the last operation is, is returned from the subflow as the new "message" of the flow, but really, I don't care about the value from the "ensure data present" subflow. I need instead to keep working on my original message, but still wait for the different subflows to finish before i can run my final "createItem"

Soraz
  • 6,610
  • 4
  • 31
  • 48

2 Answers2

4

You can use Aggregation Nodes: for example, use 3 flows:

  1. first would be propagate your original message to third
  2. second would be invoke operations createItemSpecificToKey1InExternalSystem and createItemSpecificToKey2InExternalSystem
  3. third would be aggregate results of first and second and invoke createItemFromInput.
Aleksawka
  • 81
  • 2
  • 2
  • 16
0

Have you considered using the Collector node? It will collect your records into N 'collections', and then you can iterate over the collections and output one document per collection.

kimbert
  • 2,376
  • 1
  • 10
  • 20