I need to implement a transaction that spans over loosely coupled (SOA+MOM) components.
When a particular event is received, FOO and BAR need to do a transactional operation: that is, both the transactions on FOO-DB and BAR-DB need to be successful or none of them. The consistency here is very important.
When the event is received (1), FOO does an operation on a database (2).
If the operation fails, nothing more happen.
If the operation is successful, a message is sent to BAR through a MOM (Kafka) (3).
BAR does an operation on another database (4).
If the operation fails, the operation previously done on FOO-DB must be reverted (5, 6).
If the operation is successful, all is fine.
Right now I'm using Kafka. I like its simplicity and speed, but I'm open to consider other solutions if they would make this situation easier to implement/maintain/extend.
I'm quite new to SOA and MOM architectures and patterns, so I'm wondering:
- is this a common scenario/pattern?
- how is this commonly implemented?
- the simple means offered by Kafka are enough to reliably implement this or I would be better considering other solutions?
- is the distributed transaction manager usually provided by the MOM or by the database? and if it is the DB, how can this be done using different DBs?
Sorry for the many questions, I hope they're not too much for a single question. Thank you!