EVENT DRIVEN
ARCHITECTURE
       Chris Patterson
Senior Architect, RelayHealth

   Chris@PhatBoyG.com
Agenda

Review Enterprise Application Integration
Introduce Event Driven Architecture
Define Events
.NET sample using MassTransit
About Me

Enterprise Software Architect
20+ years in commercial software development
12+ years at a Fortune 15 company
Proven history with distributed, real-time systems
2009 - Awarded Microsoft Visual C# MVP
ENTERPRISE APPLICATION
    INTEGRATION
ENTERPRISE APPLICATION
    INTEGRATION

Linking applications in an organization together to
    simplify and automate business processes
Shared Database

Multiple applications coupled to single schema
Unclear ownership of schema
Blurred application boundaries
Linked servers (SQL to SQL RPC)
Changes often affect multiple applications
File Transfer
File Transfer
Extract - Transform - Load (ETL)
File Transfer
Extract - Transform - Load (ETL)
Asynchronous
File Transfer
Extract - Transform - Load (ETL)
Asynchronous
Simple interoperability through common formats
File Transfer
Extract - Transform - Load (ETL)
Asynchronous
Simple interoperability through common formats
Timeliness of data can lead to inconsistencies
File Transfer
Extract - Transform - Load (ETL)
Asynchronous
Simple interoperability through common formats
Timeliness of data can lead to inconsistencies
Large data volume containing unrelated data
File Transfer
Extract - Transform - Load (ETL)
Asynchronous
Simple interoperability through common formats
Timeliness of data can lead to inconsistencies
Large data volume containing unrelated data
Ownership of files, cleanup, versioning
Web Services
Explicit Contract (WSDL, DataContract)
Synchronous Operation leads to sequencing
Services must be available at invocation
Nested call stacks fragile, consume resources
Remote Procedure Call (RPC, COM, CORBA)
The network is unreliable
RPC Exchange
Prepare      Call




Return      Process
RPC Exchange
Prepare      Call




Return      Process
RPC Exchange




                             e
                          bl
                           ia
Prepare                          Call




                        el
                     nr
                    U
                re
               As
             rk
Return                          Process
          wo
      et
     N
MESSAGING
Message Exchange

Create      Process



Send        Receive
A-Synchronicity

Message producers are non-blocking
  Fire and forget
Message consumers run in their own process
Introduces a more complex programming model
Minimized Coupling


Eliminates temporal coupling
Enables isolated testing of services
Reduces dependencies, increasing service reuse
Explicit Contract

Agreement between producer and consumer
Internal data structure remains private
Integration points remain at the application’s edge
Eliminates propagation of internal changes
Fault Tolerance


Messages improve recoverability
Durable message transports
Data Availability


Enables small, frequent transfers of related content
Distribute system load over a wider time window
EVENT DRIVEN
ARCHITECTURE
EVENT DRIVEN
       ARCHITECTURE
A method of building enterprise systems in which events
   flow between decoupled components and services
Another Architecture?

Service Oriented   Event Driven
  Architecture     Architecture
Service Oriented   Event Driven
  Architecture     Architecture




    Complimentary
Service Oriented   Event Driven
  Architecture     Architecture




    Complimentary
SOA 1.0

Applications are composed using a designer
Synchronous programming model
Step-by-step (F10) flow through services
Majority of interactions are request/response
Event Driven Architecture

Components are assembled at run-time
Asynchronous programming model
Reactive behavior
Leverages one way, fire and forget, messaging
Autonomous Components

Defined by responsibility
Independent
Self-governing - makes decisions on how to react
Self-controlling - responsible for execution context
Self-contained - not part of an application
Event Producers


Publish events
Oblivious to consumer reactions
Unaffected by high number of consumers
Event Consumers


React to events
Subscribe by topic/type/selector
Asynchronous operation
Business Components


Logical grouping of autonomous components
Represent a complete business process
COMMANDS
Commands

Tell a component or service to do something
Initiated by an event, interaction, etc.
Use correlation for tracing, idempotence
Sent using messaging (not published)
Reset Password


User initiates a password reset
Password service sends reset email
User clicks link in email
Message Body

public class ResetPassword
{
  public Guid RequestId { get; set; }
  public string Username { get; set; }
}
Compared To...

public void ResetPassword(string username)




  public class ResetPassword
  {
    public Guid RequestId { get; set; }
    public string Username { get; set; }
  }
EVENTS
Pablo’s Fiesta!
    February 26, 27, 28
         Austin, TX
       Open Spaces
    fiesta.lostechies.com
EVENTS
EVENTS

Represent a change in state
Self Contained

A pure and complete representation of a specific event
Time relevant, not time sensitive
Avoid references to internal data
Reduces dependencies, loosens coupling
Identified



Each event should have its own unique identifier
Related


Related events should share a common identifier
  Allows event tracing (the new F11)
  Assists in combining events into processes
Observed


Events are published as messages
Multiple components can subscribe to the same event
EVENT TYPES
Business Events
Map to real world events that occur in business


Item Added to Cart
Invoice Received
Order Shipped
Payment Requested
Lifecycle Events
Notifications related to the life of a state or process


  Preparing Shipment / Shipment Prepared
  Authorizing Payment / Payment Authorization
  Complete
  Session Started / Session Completed
Management Events
Relate events to time, ranges, limits


Timely Service Guarantee Exceeded
  Your order within five minutes, or it’s free
Popular Item Notification
  Items with a 5x increase in sales in an hour
MassTransit Key Points

Lightweight Service Bus Implementation
Loose coupling via publish/subscribe
Active Service Pattern
Supports MSMQ, RabbitMQ, 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
Logging


Thorough logging with correlation information
Log level configurable at runtime
Visualization Tools


Present code-based logic in a visual form
Aid in identifying composition problems
Should be viewable on operational systems
GITTING
MASSTRANSIT
Source Repository
Latest Build
Documentation
FOR MORE
INFORMATION
Reading Material
Reading Material
Reading Material
Reading Material
Reading Material
Reading Material
Reading Material
CONTACT ME
      Chris@PhatBoyG.com
http://PhatBoyG.LosTechies.com
       twitter: @PhatBoyG
   voice: text “cmp” to 50500

Event Driven Architecture at NDDNUG

Editor's Notes

  • #4 Soft real time systems
  • #42 Soft real time systems