The Hollywood Principle - 17.09.2018
Remember when you were a child, going on a long trip with your parents. Remember the frustration; “Are we there yet?”, “Are we there yet?” Now, as an adult - imagine or remember your own frustration from being nagged! Review date - 17.09.2018
For both parties, this pattern is not ideal; children are frustrated with not knowing, while parents are frustrated with constantly being nagged. So, why do we think this pattern is OK in software architecture? Why do we ask systems to constantly check other systems for updates? Why do we allow this tight coupling?
Fortunately, computers are not human; they have no emotion nor a concept of time. They don’t mind constantly asking other systems for an update and other systems don’t mind being asked. All they do is check again and again so they can do something. This constant chatter between systems can, and does, have an impact. So, instead of asking systems to constantly "check for an update", why not configure them to react to an event – tell them; “I’ve done something you may want to know about”.
When something happens in Hollywood – the world knows about it; whether we choose to do something about it is our own decision. A reporter writing the story about an event does not know who will read the story or what they will do with the information they receive. The reporter only expects the newspaper will publish the story for all its subscribers to read.
In software architecture, we can publish business events using the publish-subscribe pattern (PubSub). Interested systems can subscribe to events based on an event topic and decide for themselves, what to do with the data received. In essence, when the source system has done its bit, it can publish data about the event via PubSub to the subscribers. Decoupling is important; the source system does not, and should not, care about what the subscribers do with the data – they have already completed their task.
Since the subscriber consumes the event data for their own purposes, it is their responsibility to complete their task within their bounded context. So what happens if the subscriber fails to react to the event (via an error or broken communication)? Is it viable to ask the publisher to replay the event? No! The subscriber cannot assume they are the only audience of the event. Just like the publisher is not aware of the subscribers, subscribers should also not be aware of one another. Imagine republishing an event that leads to duplicate communications to customers or duplicate actions!
- publish event data via persistent queues to ensure delivery, and/or
- expose APIs for retrieving published event data for reconstitution queries in the event of an error by the subscriber.
While PubSub does seem like a simple pattern, implementation can be challenging. Publishing a single event using Change Data Capture (CDC), of multiple tables, is just one of those challenges. That's a whole new ball-game and a subject for another day.
You can find more information and articles via my LinkedIn profile.
Banking reviews to your e-mail!
- Bank and Clients
- Bank Leumi
- Bank Mandiri (Europe)
- Bank of America Merrill Lynch
- Bank of Beirut
- Bank of Ceylon
- Bank of China
- Bank of Communications (UK)
- Bank of Cyprus (UK)
- Bank of Ireland (UK)
- Bank of London and The Middle East
- Bank of New York Mellon
- Bank of Scotland
- Bank of the Philippine Islands (Europe)
- Bank Saderat
- Bank Sepah International
- Barclays Bank
- BIRA Bank
- BMCE Bank International
- British Arab Commercial Bank (BACB)
- Brown Shipley & Co
- Butterfield Bank (UK)