Tips and Tricks on Building Event Driven Architectures with Windows Azure Service Bus
Just now I did a presentation at Visual Studio Live @ Redmond under the topic “Tips & Tricks on Building Event Driven Architecture with Service Bus”.
One of the very interesting things to understand is that a lot of us already use Event Driven Architectures even without knowing it. That was one of the parts I explained in the session, since a lot of us currently use messaging mechanisms to decouple our solutions, and that’s already building things in an event driven way.
A summary of the session for the people who didn’t attend is:
- What is Event Driven Architecture?
- Architecture Pattern that orchestrates behavior around:
- Production
- Detection
- Consumption of events
- Method for building decoupled enterprise solution
- Suited for Async and unpredictable environment (like the cloud for example)
- Has 3 types of processing:
- Simple Event Processing
- Events that are directly related to specific and measurable changes
- Stream Event Processing
- Events that can be notable (important) or ordinary (not so important)
- Complex Event Processing
- Both Notable and Ordinary events allowing to search for patterns
- What is Windows Azure Service Bus?
- Connectivity
- Service Relay
- Protocol Tunnel Eventing
- Messaging
- Queuing Pub/Sub
- Reliable Transfer
- Svc Management
- Naming, Discovery
- Monitoring
- Integration Routing
- Coordination Transformation
Going now for the Tips & Tricks
- Choose your Event Stream wisely
- Messaging (Applicable when you need reliability)
- Windows Azure Service Bus Queues
- Windows Azure Service Bus Topics
- Windows Azure Storage Queues
- Relay (Applicable when you don’t need reliability but only a way to sent a message to all the subscribers)
- Twitter (Never forget the power of Twitter. For example http://twitter.com/fltadvisor provides you information about flight delays in US. Why not leverage Twitter to do the same for your app?)
- RSS Feed (Also very interesting. For example Windows Azure Service Dashboard uses RSS Feeds.)
- Other sources
- Create different types of messages, DON’T GENERALIZE IT
- One of the important parts is never generalize event types.
- You have 4 types of events you need to work on
- Business
- Execution
- Lifecycle
- Management
- Those are the type of events but you shouldn’t generalize because each event has it’s own properties that are notable for them. For example a DataChangeEvent is different from a NotificationSentEvent. Do the two, don’t generalize into one only with different types.
- Choose the right Event processing Type
- Simple Event Processing
- Use it whenever you need to handle events in a simple way, without having differences between the events. You just need to process all of them.
- Eg.
- Coordinating Worker Roles
- Stream Event Processing
- Use this whenever you need to handle events in a simple way, but you have different types of events with different importance, like Notable and Ordinary events.
- Eg.
- Notification System that received events but some are priority notifications and other non-priority
- Complex Event Processing
- Use this whenever, and only, when you need to search for a pattern inside the event stream. if not, don’t use it.
- Eg.
- Stock Exchange. If the Index A goes up 20% and Index B goes up more than 5% in a 5 min period. Do Something
- Keep your modules Loosely-Coupled
- Event Driven Architecture is all about decoupling every module of the solution, so continue with that. Do you modules as they don’t need to know who creates the events and why they do it.
- ‘Shard’ your Event Stream
- It’s important to think from the start how you are going to shard your Event Stream, because if the solution is going to be unpredictable in growth you need to be prepared.
- Some simple way is to think Sharding on the Type (Business, Execution, Lifecycle, Management) but then you can for further.
- Consider Windows Azure IaaS with Microsoft StreamInsight for Complex Event Processing
- Very interesting product for Complex Event Processing and that can easily be placed in the Cloud, and of course Windows Azure Virtual Machines
- Consider ‘Project Austin’ from Microsoft
- This is really good since it’s Microsoft StreamInsight as a Service in Windows Azure
I presented a sample based on this http://www.codeproject.com/Articles/55620/Event-Driven-Architecture-in-the-Clouds-with-Windo that can’t be found here http://eventdrivensample.cloudapp.net.
Also very interesting to check out is the new CQRS Journey from Microsoft Patterns & Practices here.
Hope this helps you in future developments, and also I’d love to hear you thoughts about this, so please comment and let’s build a conversation about it and generate other posts.