Coffee, Donuts and Asynchronous Message Handling
I love coffee and donuts almost as much as I love being a software developer. But this morning I had a moment of clarity during my daily indulgence.
I stroll into the blur of activity that is the Dunkin Donuts near the riverside entrance ramp of Olgilvie Train station. An Indian woman behind the counter turns, smiles, points at me then asks, “Can I help you?”
“Uh, yes, extra-large cream and sugar.” Before I am finished with my sentence she has already turned back to the coffee machine with an extra-large coffee cup in her hand.
To my right the bespectacled gentleman behind the cash register is swiping the credit card of another customer who arrived seconds after me. But she doesn’t have her order yet. As the receipt is printing he turns to me and asks if I need anything else.
“Yes, one chocolate glazed.”
Meanwhile the woman with my coffee turns to him and says, “Extra large coffee” and deposits the coffee on the counter. I begin munching on my donut that some anonymous person had already placed on the counter. She’s already getting coffee for the lady to my left. The lady who paid as I began my order takes her sandwich order directly from the sandwich person and leaves.
As I pop the top on my coffee cup to sample the merchandise and check for adequate cream and sugar the cashier recites my order. “Extra large cream and sugar. Chocolate glazed. Anything else?” Nope, I hand him my credit card.
As he swipes my credit card a lady to my left asks, “Does bacon come on the flatbread sandwich?” While the receipt prints out he turns to his left and taps the sandwich maker to alert her to the customer. The sandwich maker comes around to speak with the customer. The cashier hands me my receipt.
As I step out of the donut shop into the throng pushing towards the rotating doors I realize that I have just been processed through an Asynchronous Message Handling System.
The system consists of individuals who know what they can do and how to alert the other workers of things they cannot. Each individual piece of the order can be broken down and handled by the appropriate individual then each individual hands off their completed work to another. The entire request can be rolled up and completed prior to any individual portion of the process has itself completed. Of course not everything is perfect, and there is a similar process to handle mistakes by any one piece of the process. But overall I think it is a good analogy of how multi-threaded, asynchronous systems like BizTalk and WF work using patterns like the Publish-Subscribe.
I love software.