Event Driven Architecture
             Chris Patterson
      Senior Architect, RelayHealth

         chris@phatboyg.com
Agenda

Enterprise Application Integration (EA-eye)
Events
Event Driven Architecture (ED-eh)


.NET sample using MassTransit
About Me

Enterprise Software Architect
Over 20 years of software development experience
Over 11 years at a Fortune 15 company
Proven track record with distributed, real-time systems
Enterprise Application Integration
Enterprise Application Integration

The process of linking applications within a single
organization together in order to simplify and automate
business processes


While avoiding sweeping changes to existing applications
File Transfer

Applications export and import files
Use various formats, requiring translation
Often loaded manually, infrequently
Affectionately known as ETL or SSIS
Shared Database

The mastermind of the axis of evil
Data is tightly coupled to multiple applications
Incremental, partial upgrade of application impossible
Primary reason for “forklift upgrades”
Web Services

Requires service to be available at invocation
Results in multiple call stacks, consuming resources


Yet another Remote Procedure Call (RPC, COM, CORBA)
Messaging
Messaging
Messaging

Defined data format
Asynchronous operation
Minimized coupling
Fault tolerance
Data Freshness
Defined Data Format

Mutual contract between producer and consumer
Internal formats remain private
Integration code remains at the edge of the application,
preventing internal changes from impacting the interface
Asynchronous Operation

Processes run in their own execution context
Originating process continues
Services need not be available at all times
Minimized Coupling

Additive model reduces change to existing systems
Reduces dependencies, increasing service reuse
Enables isolated testing of services
Fault Tolerance


Durable messaging improves recoverability
Compensating actions to handle partial failure
Data Freshness


Favors small data transfers of related data
   compared to big files containing unrelated content


Minimizes data exchange latency
Events
Events

Represent a change in state
Self-contained
Uniquely Identifiable
Time relevant, not time sensitive
Sourced using messaging
Unique Identification

Enables idempotent handling of events
Improve traceability of related processing
Allows correlation with related events
Self Contained

A pure and complete representation of a specific event
No references to other data sources
No need to time sync to an additional source
Reduces dependencies, loosens coupling
Observable


Published events can be observed by multiple subscribers
Event stream processing
Event Types
Execution Events
Define the process flow


Order Coffee
   Customer placed an order for coffee
Present Coffee
   Coffee handed to customer
Lifecycle Events
Bookends around the process


Preparing Coffee
   Barista began preparing a coffee
Coffee Prepared
   Barista finished preparing a coffee
Management Events
Time period elapsed, Range or limit exceeded


Order Guarantee Exceeded
   Your order within five minutes, or it’s free
Caffeine Junkie Alert
   Orders of ten or more coffees require approval by FDA
Business Events
Found by observing the natural order of the business


Coffee Order Fulfilled
   A coffee was ordered, prepared, and delivered
Material Shipment Arrived
   Beans, milk, and cups delivered by brown
Event Driven Architecture
Event Driven Architecture

A method of building enterprise systems in which events flow
between decoupled components and services
A maintainable, sustainable, and extensible model for
building complex, distributed applications
Well suited for asynchronous, unpredictable environments
How is it different from SOA?
How is it different from SOA?


Event Driven Architecture
   complements

Service Oriented Architecture
Service Oriented Architecture

Applications are composed at design-time
Linear flow between services
Predictable behavior
Request/Response is common, overused
Event Driven Architecture

Applications are composed at run-time
Asynchronous components
Reactive behavior


Natural fit for distributed systems
Autonomous Components

Triggered in response to an event
Independent - no coupling to event producer
Self-governing - makes decisions on how to react
Self-controlling - responsible for execution context
Self-contained - not part of an application
Event Producers


Publish messages representing an event
Often oblivious to the consequences of the generated event
Event Consumers

Subscribe to events by topic/type/selector
Handle events asynchronously
No performance penalty for additional consumers
MassTransit Key Points

Lightweight Service Bus Implementation
Loose coupling via publish/subscribe
Active Service Pattern
Supports MSMQ, ActiveMQ, TIBCO EMS
Open Source, Apache 2.0 License
“Event Driven
Architecture is...
programming without a call stack.”
      -Gregor Hohpe, Google
Testing

Individual components testable in isolation
Fully unit-testable using mocks and stubs
Test-first development helps improve data contract
Debugging


Logging
Visualization Tools
Logging


Thorough logging with correlation information
Adjustable output configurable at runtime
Visualization Tools

Present code-based logic in a visual form
Aid in identifying composition problems
Should be viewable on operational systems
For More Information
Reading Material
Reading Material
Reading Material
Reading Material
Reading Material
Reading Material
Reading Material



Enterprise Integration Patterns (Hohpe, Woolf)
Patterns of Enterprise Application Architecture (Fowler)
SOA Patterns (Arnon Rotem-Gal-Oz, Eric Bruno, Udi Dahan)
Web Sites

MassTransit - http://masstransit.googlecode.com/
Topshelf - http://topshelf.googlecode.com/
Magnum - http://magnum.googlecode.com/
Contact Me
      Chris@PhatBoyG.com
   http://blog.PhatBoyG.com
 http://twitter.com/PhatBoyG
http://PhatBoyG.LosTechies.com

Event Driven Architecture