Rebound & Integration: Making Sure No Data Gets Lost When Synced
The elastic.io platform connects and keeps different systems in synch using their APIs. Read on to hear about the elastic.io platform and its Rebound feature.
Join the DZone community and get the full member experience.Join For Free
the elastic.io platform connects and keeps different systems in synch using their apis. all of this is done despite their different hierarchical structures with inter-object dependencies, different data types, and different locations. it would seem to be an impossible task to achieve, especially in the current distributed computer systems where the problem of common state or consistency can really hamper the success of your integration solution. to prevent this from happening in the first place, we have several built-in "hidden features" in our integration platform. in this article, we will reveal one of those features called rebound . rebound ensures an eventual consistency for integration processes run on elastic.io platform.
the practical need for eventual consistency
here is how the problem can happen in practice. we have a task to synchronize orders and customers between two complex systems like erp and an online shop.
- customers register in shop and place their orders.
- each order contains a reference to a customer, so that no order could be created in erp before a customer is created.
two separately running parallel integration processes are created:
- process a synchronizes customers.
- process b synchronises the corresponsing orders.
as two processes are running in parallel, we could run into a situation where an order arrives earlier than the corresponding customer data. this would prevent that particular order from being created in erp and could potentially lock the system, blocking the further processing. this is a simple example of hierarchical data structures with inter-dependencies that require some safeguarding to ensure consistency in the distributed systems (erp & shop).
check out the example of sap by design erp connection with commercetools run online shop.
the theory behind the eventual consistency
in theoretical computer science we are faced with the uncertainty of three states which are the consistency , availability , and partition tolerance (the cap theorem). for a distributed computer system, it is impossible to guarantee all three states simultaneously . one or two of these states would need to be sacrificed if one would try to seek an absolution in one state only. instead, synergistic or partial solutions can be devised. it is not the scope of this article to present all of the solutions to this dilemma–werner vogels, the cto of amazon.com has written more on this .
here we will talk about one of the widely accepted and used solutions in the distributed computer systems called eventual consistency :
"eventual consistency is a consistency model used in distributed computing to achieve high availability that informally guarantees that, if no new updates are made to a given data item, eventually all accesses to that item will return the last updated value."
– wikipedia, eventual consistency
in all of its glory, eventual consistency is not a flawless solution partly because eventual consistency is a liveness guarantee . this means it can keep the system alive (free from deadlock) and progress further despite the errors. what we would need to do for safeguarding is use sets of concurrent systems to reschedule or send messages back for reprocessing. this kind of safeguarding is called the bounded bypass which is implemented at elastic.io to reach the eventual consistency for integration processes.
reaching eventual consistency through rebound at elastic.io
coming back to the example above, when we try to synchronise an order in erp while the customer data for that order is not yet in place, we’ll simply postpone the processing of that order for a while. by doing that we give the parallel process more time to synchronize customers, and hope that the corresponding customer information would eventually be synched with the erp. this is a clear example of eventual consistency application in the integration processes. to reach the eventual consistency we use one of the built-in features of elastic.io integration platform– rebound .
- rebound is a feature that adds a possibility to bounce back and reprocess the incoming messages when the system is not ready to process them at that particular instance.
when the message cannot be processed by the component due to insufficient information, it is sent back or rebounded. this means that the message is sent to a special queue where it waits for a minute and then re-queued for a repeated processing by the component. in case the message is rebounded again, then the waiting period is consequently increased with each iteration. this process can happen several times (currently, it’s set to repeat 10 times in our system), after which the message is rejected completely and an error is reported.
this simple yet powerful solution ensures eventual consistency in integration processes which does not require a central coordinator (e.g. xa transaction manager, or distributed locking). it is highly available, but at the same time, one needs to understand its drawbacks, e.g. in our sample the data synchronisation may happen out-of-order and get delayed.
in our documentation section we also have samples of code explaining the exact usage of the rebound feature in the elastic.io platform.
Published at DZone with permission of Olga Annenko, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.