Transactions vs Events

Reading Time: 3 minutes

It is interesting that many of use see the world in terms of transactions: I withdraw money from an ATM and my bank balance is summarily adjusted; I book a Cinema ticket and the number of available seats are reduced by one. In IT, the world of “transactions” is closely associated with (traditional synchronous) “services”: I call a service and it responds. And if some transaction embeds multiple service calls then any failure of any of these services can result in the transaction being backed out; if the ATM doesn’t give me my money then my bank balance is readjusted back to what it was. Usually. Sometimes. Maybe after a few phone calls to Bank Customer Services (in my most recent example…).

A recent trip by sleeper train to Edinburgh, Scotland, demonstated to me some issues with the  “transactional view” of the world:

  1. Lets book 2 sleeper cabins for 2 adults and 1 child: “my” transaction here involves the child  sharing a cabin with an adult in the same family – not an unusual requirement one would have thought. However the booking system separates tickets into different types such as Adult and Child. Ergo, there was no way for the IT service to enable me to book an adult and child in the same cabin at the same time…
  2. The web site was a little confusing, and I ended up with “sleeper seats” (that were booked in pairs as if cabins). Of course, these turned out not to be sleeper cots but just normal seats in which one “could sleep”. Hmmm.
  3. For the return journey I asked an expert to navigate the “service system” on my behalf (i.e. I went to the ticket office!). Here I noticed the ticket office user interface was strongly reminiscent of the web booking system… except the ticket clerk could complete a “family transaction” by temporarily booking the tickets, then cancelling them out if needed. End result: 2 cabins booked for the return journey (although adjacent, we could not tell if they were interconnected cabins…).
  4. The ticket inspector on the return jouney was not happy with these cabin tickets, it turned out. It seems the upgrade from class X to class Y for the return was, in his opinion, invalid. A simple rule not being enforced in the booking system? Regardless, there were plenty of spare cabins and the inspector manually re-allocated cabins to ensure interconnecting cabins for groups like ours.
  5. Postscript: After all that, it seemed I slept worse in the cabin cot than I had done in the seat on the way up!

Transactions are always in the context of some system or resource (railway cabin cots, bank balance, etc), and multiple contexts can be present at the same time (the train capacity versus the need for a family to travel together). From an event processing perspective:

  • transactions are also events: start transaction, end transaction, failed transaction etc
  • rolling back transactions can be expensive (for multiple parties concerned) and businesses should monitor such events in case of avoidable issues
  • handling and coordinating complex transactions should of course be automatable in many cases (with appropriate business constraints and rules adhered to); in other cases they are a primary driver for BPM and workflow applications
  • dealing with the consituent events in a transaction, inter as well as intra transactions, allows more optimised business responses due to the smaller granularity of details.

High performance event processing technologies like TIBCO BusinessEvents can be exploited to handle business transactions (like any other business interactions). Such tools can exploit high throughput, low latency, failover and fault tolerence support, with the ease of applying rules to transaction events and built-in activity monitoring. Such tools also provide the features needed to support transactions, such as:

  • the use of locking on distributed objects if there is a risk of simultaneous updates
  • allowing transactional data is persisted (as well as distributed across memory) using something like Cache Aside mode, where updates to objects are stored in a DBMS in case of things like power failures
  • explicit transactional data systems such as TIBCO ActiveSpaces Transactions can be used to handle transactional issues alongside the event processing.