ebook img

Event-driven Architectures PDF

16 Pages·2007·0.5 MB·English
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Event-driven Architectures

Programming without a Call Stack - Event-driven Architectures W-JAX 2007 Gregor Hohpe | Google Programming Without a Call Stack: Event-driven Architectures www.eaipatterns.com Who's Gregor? (cid:122) Distributed systems, enterprise integration, service-oriented architectures (cid:122) MQ, MSMQ, JMS, TIBCO, BizTalk, Web Services eaipatterns.com • Patterns (cid:122) Write code every day. Share knowledge through • Articles patterns. • Blog Enterprise Integration Enterprise Best SOA Integration Patterns Solution Software Experten- Patterns Microsoft Patterns Writing I wissen Addison-Wesley Press Microsoft APress dpunkt Verlag Press 1 1 Programming without a Call Stack - Event-driven Architectures W-JAX 2007 Agenda (cid:122)It's All About Coupling (cid:122)Events Everywhere (cid:122)Event-driven Architectures (cid:122)Developing in an EDA (cid:122)Case Study: Building an EDA in JavaTM 2 In A Connected World It's All About Coupling "Measure of dependency between components" 3 2 Programming without a Call Stack - Event-driven Architectures W-JAX 2007 Dynamic Composability "The ability to build new things from existing pieces." 4 Interaction Takes Center Stage "The lines are becoming boxes now." --Ralf Westphal 5 3 Programming without a Call Stack - Event-driven Architectures W-JAX 2007 The World is Full of Events Ware Shipping house Partner Inventory Truck Low Delayed E-mail Order New Order Event Bounced Mail Entry Gateway Cloud Address Credit Card Changed Payment Expired Declined Web Financial Site System 6 Event-Driven Architecture (EDA) Channel Node Event (cid:122)Distributed processing, no central control. (cid:122)Nodes respond to incoming events and publish events in response. (cid:122)Event channels transport events from one node to the next, usually asynchronously (sender does not wait). (cid:122)Composition through channels. 7 4 Programming without a Call Stack - Event-driven Architectures W-JAX 2007 EDA Defining Qualities (cid:122) Timeliness. Publish events as they occur AA instead of waiting for the next batch cycle. (cid:122) Asynchrony. The publishing system does not Event wait for the receiving system(s) to process the AA BB Queue event. (cid:122) Fine Grained. Publish single events as AA opposed to large aggregated event. Orders (cid:122) Ontology. A nomenclature to classify and On-Line express interest in certain groups of events. Updated New (cid:122) Complex Event Processing. Understanding the relationships between events, for example aggregation and causality. 8 Composition via Channels Channel X System System A publish subscribe B (cid:122)Nodes communicate via Channels (cid:122)Sender and receiver need to agree to a common channel. This is a form of coupling. (cid:122)Sender and receiver have to decide which channel is “right”. The burden can be shifted between sender and receiver. (cid:122)Channel namespace provides some structure. 9 5 Programming without a Call Stack - Event-driven Architectures W-JAX 2007 Channel Naming and Semantics CreditService Order Credit (cid:122)Target component Entry Service VerifyCreditCard Order Credit (cid:122)Action / Operation Entry Service PaymentInfo (cid:122)Document Order Credit Entry Service OrderReceived (cid:122)Event Order Credit Entry Service 10 How Do A and B Connect? Structured (cid:122) Channel Name / Instance MessageQueue q = new MessageQueue(“foo"); • Common in message queue systems. • Limited expressiveness. q.Send(“Msg”); (cid:122) Topic Hierarchy Orders • Allows wildcard subscription On-Line • Requires mapping of topic space onto a tree. Forces prioritization. Updated New (cid:122) Content-based Channel.Subscribe( • Flexible, but difficult to implement “/element/foo=‘bar’” efficiently in widely distributed systems. ); Unstructured 11 6 Programming without a Call Stack - Event-driven Architectures W-JAX 2007 Composition Strategies (cid:122) Implicit Composition (cid:122) Explicit Composition cchhaannnneell == CChhaannnneell..bbyyNNaammee((““oorrddeerrss””));; AA((CChhaannnneell cchh)) {{ tthhiiss..cchhaannnneell == cchh;; }} cchhaannnneell..ppuubblliisshh((mmeessssaaggee));; …… cchhaannnneell..ppuubblliisshh((mmeessssaaggee));; A A Channel <<create>> orders “Composer” Channel B B cchhaannnneell == CChhaannnneell..bbyyNNaammee((““oorrddeerrss””));; BB((CChhaannnneell cchh)) {{ tthhiiss..cchhaannnneell == cchh;; }} cchhaannnneell..ssuubbssccrriibbee((eevveennttHHaannddlleerr));; …… cchhaannnneell..ssuubbssccrriibbee((eevveennttHHaannddlleerr));; 12 Event Collaboration Multiple Components work together by communicating with each other by sending events when their internal state changes. (Fowler) Order Customer Shipping Management Management Request Order RequestFor Address Collaboration Address SendShipment Order Customer Shipping Management Management Event Order Address Changed Collaboration 13 7 Programming without a Call Stack - Event-driven Architectures W-JAX 2007 Event Collaboration (cid:122)Adding Consumers is Side-Effect Free • Debugging / logging / sniffing • Parallel implementations (cid:122)Simple components, more complex interactions (cid:122)Robust against unstable connections (cid:122)Can be difficult to manage and /or debug • Need to understand relationship between events • Shift burden from design-time to run-time (cid:122)Components may operate on stale data 14 Event-sourced Systems Capture all changes to an application state as a sequence of events. (Fowler) Persisted State (Snapshot) Local Domain State Objects State Event Bus Changes Event Log 15 8 Programming without a Call Stack - Event-driven Architectures W-JAX 2007 Event-sourced Systems (cid:122)More than an event log or "temporal database" (cid:122)Rebuild state based on events by re-executing behavior (cid:122)Temporal Query • Determine application state at specific point in time (cid:122)Event replay • Run "what if" scenarios or corrections to past events (cid:122)Limitation: code changes 16 Composite Events Processing (cid:122)Understand causality (cid:122)Some events are the result a of a sequence of events Causality (cid:122)CEP = Complex Event Processing (cid:122)Pattern matching languages can be challenging Aggregation 17 9 Programming without a Call Stack - Event-driven Architectures W-JAX 2007 Case Study – Existing System OOnn--lliinnee CCooppyy RReeppoorrtt CCoommppuuttee DDBB PPrroocc DDBB PPrroocc UI Client A B FFrroonnttEEnndd C (cid:122) Compute statistics based on responses to on-line questionnaires (cid:122) Responses stored in database (cid:122) At the end, stored procedure computes “scores” based on user responses • Load on RDBMS • Single thread, monolithic, synchronous • Poor response time at end of user session (cid:122) Goal: scalable, extensible architecture 18 Case Study – New Architecture Event-driven LLoogg UI Client Calculators A B FFrroonnttEEnndd PPeerrssiisstteennccee DDBB C (cid:122) Decompose logic into individual “calculators” (cid:122) Calculators precompute results as response events arrive (cid:122) Channels connect calculators (cid:122) Calculators do not updates database (cid:122) Persist results into database once all scores computed (cid:122) Pure Java (1.4) implementation 19 10

Description:
Patterns. Microsoft. Press. Best. Software. Writing I. APress eaipatterns.com. • Patterns. • Articles Event-Driven Architecture (EDA). ○ Distributed
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.