How to deal with branched integration linked to an endpoint

When creating more complex integrations, we sometimes cannot avoid branching. This can be due to the need for scaling and thereby optimizing the resources used or because we need to apply a certain filter to the data and process it in different ways based on that.

The inconvenience arises if we use branching and need to return data as a response from a linked endpoint. At the design stage, we must designate a single step as the endpoint’s output, so we have no way to access data from the other branches.

The situation is well illustrated by the following example, which simulates the work of a balancer distributing payments among payment terminals. The branch through which the data flow will pass is not known at the time of publishing and will be decided based on the input data at runtime.

With the Multi-Input Step approach, we can easily address this situation by adding a synchronization step that can be connected to the endpoint. In this step, we’ll send outputs from all branches and select the one that is filled. Then, we will be able to perform any necessary transformations, if needed.

Therefore, let’s add a new step at the level of the existing three (+ by the blue arrow) and choose the JS Mapper connector, version higher than 3.3.0, as the connector. We cannot place the step after any of the steps because, due to the flow’s dynamics, we wouldn’t have assurance that it would get triggered.

We used a connector that supports what is known as multi-input, which resulted in a small plus symbol appearing next to the connector’s input. By clicking on it, we are able to select additional data sources and complete the input mappings. Consequently, we will add all three payment steps, leaving the primary one blank.

Once such a process is initiated, only one secondary input (inputData2, inputData3, or inputData4) will be filled in the step, making it quite simple to identify the input branch. With a simple script, the data can be appropriately modified and, if necessary, sent to the output, from where it can be returned as a response to the endpoint.

And what’s the result? With this simple trick, we’ve not only synchronized our integration flow but also demonstrated how to easily handle different data formats originating from branches and seamlessly return them through the endpoint.

Conclusion:

The Multi-input step provides a simple yet effective solution for streamlining complex integration processes that require branching. By introducing this approach, we’ve shown how to easily synchronize data from different branches, making integrations more flexible and robust. This feature is an excellent example of innovation that simplifies developers’ work and opens up new data processing and integration possibilities.

1 Like