Wednesday, August 6, 2014

Event Driven Architecture and Retail

For those of you who don't know me, I currently work in the retail industry.  Software written for the retail industry is prime for Event-Driven Architectures (EDA).

Almost everything that occurs in a store is an event:
  • Completed sale
  • Inventory arrived at store number 123
  • Inventory loaded on to a trailer 321
  • Sales start
Events in a retail enterprise stream from system to system.  These streams are defined by business processes like an Item Setup process or a Sale Process.  For example, when a Sales Complete event occurs, both the accounting and inventory systems take action.  The accounting system posts the sale to that stores ledger.  The inventory system decrements that item's store count.  A change in store count below a threshold could in turn trigger an Inventory Low event.  A replenishment system at the warehouse gets notified of this event and schedules a replacement item be pulled from the warehouse stock and be shipped on the next available trailer.  Now if the warehouse stock is below a threshold, it could then fire a Stock Low event.  In turn a purchasing system could cut a purchase order to the vendor and so on.


Historically our company performs a great deal of batch processing (COBOL on IBM mainframes), especially at night.  All of that processing has undesirable side effects:

  • table locking
  • delayed processing
  • no real time analytics
Sometimes I get asked, "Why don't your stores open at 12am on black friday like Wal-Mart or Target?".  The simple answer is "We can't!"  When batch is running, we cannot post sales due to table locks and our batch runs from 11pm to 5am.

Apply that situation to the data flow above.  The accounting and inventory system is working with yesterday's data.  Replenishment is working with data 2 days old.  The poor purchasing system is utilizing 3 day old data.

Okay that is a bit of an extreme example, but the point is still valid.

I'm not saying that there isn't a place for batch processing in retail because I believe that there is a place for it.  What I'd like to see is a drive in using EDA within our shop and in our B2B relationships.  Let the events stream!

Maybe soon I'll look at reactive streams and some frameworks which implement it like Akka streams and RxJava.