Enterprise Application Architectures by Dr. Indika Kumara

65
Enterprise Application Architectures Dr. Indika Kumara 1

Transcript of Enterprise Application Architectures by Dr. Indika Kumara

Page 1: Enterprise Application Architectures by Dr. Indika Kumara

1

Enterprise Application Architectures

Dr. Indika Kumara

Page 2: Enterprise Application Architectures by Dr. Indika Kumara

2

Outline• Enterprise Applications/Computing• Architecture Styles for Enterprise Applications

– Method-oriented– Message-oriented– Resource-oriented

• REST (representational state transfer)– Event-oriented

• SOA (service-oriented architecture)– Basic and extended SOA– Implementing SOA

• RESTful • WS-* (web services stack)

– ESB (enterprise service bus)• Business processes and service compositions

Page 3: Enterprise Application Architectures by Dr. Indika Kumara

3

Characteristics of Enterprise Computing

Page 4: Enterprise Application Architectures by Dr. Indika Kumara

4

Enterprise Example : E-Book Shop

ShippingCompany

Inventory Department

Billing Department

Credit Card Company

Book PublisherCustomer

Shop Manager

External

Internal

Business Processes1. Buying Books2. Filling Inventory3. …

Page 5: Enterprise Application Architectures by Dr. Indika Kumara

5

Characteristics of Enterprise Computing

• Enterprise-wide data sharing => Lots of persistent data, concurrent access

• Long lived processes => asynchronous• Changing => loosely coupled• IT business alignment => large scale components,

business processes• Heterogeneous systems => integration, standards• Across organizational boundaries => distributed

computing, limited control, security, standardsFrom Swinburne lecture notes

Page 6: Enterprise Application Architectures by Dr. Indika Kumara

6

IT and Business Alignment

Business

Information Technology

Drives Enables/Transforms

Simplify finding an book in the store by a customer

Book Inventory Management System

E-Book Shop

Expands business globally

Enterprise Architecture => IT and Business Alignment

Page 7: Enterprise Application Architectures by Dr. Indika Kumara

7

Architecture Styles for Enterprise Applications/Computing

• What is a software architecture?• What is a software architecture style?• Four types of architecture styles for enterprise

applications– Method-oriented (Remote Procedure Call)– Message-oriented– Resource-oriented– Event-oriented

Page 8: Enterprise Application Architectures by Dr. Indika Kumara

8

Method-oriented Style(Remote Procedure Call)

Page 9: Enterprise Application Architectures by Dr. Indika Kumara

9

Remote Procedure Call• Like a function call, but

– Caller and callee are in different address spaces , usually connected through a network (not necessarily)

– Client and server model• Service Interface

– Method and parameters• Client-server Interactions

– Synchronous request-response– Request-acknowledge

• Examples: CORBA (Common Object Request Broker Architecture), Java RMI (Remote Method Invocation), and DCOM(Distributed Component Object Model )

Page 10: Enterprise Application Architectures by Dr. Indika Kumara

10

Remote Procedure Call …

Client(caller)

Server(callee)

PacketHandler

PacketHandler

call

return

send

receive

send

receive

return

call

Netw

ork

Net

wor

k

ClientStub

bundleargs

bundleret vals

unbundleret vals

ServerStub

unbundleargs

Machine AMachine B

mbox1

mbox2

From berkeley notes

Page 11: Enterprise Application Architectures by Dr. Indika Kumara

11

Message-oriented Style

Page 12: Enterprise Application Architectures by Dr. Indika Kumara

12

Message-oriented Style

• (Distributed) entities interact by exchanging messages between them

• Service Interface– Domain specific operations and message types

• Client-Server Interaction– Various form of persistent /transient and

asynchronous / synchronous communication models

– Various message exchange patterns

Page 13: Enterprise Application Architectures by Dr. Indika Kumara

13

Message Exchange PatternsOne-way

Request -Response

Solicit -Response

Notification

E.g. Order Submission

E.g. Get Available Books

E.g. Ask customer to send some information

E.g. Send Book Status

Page 14: Enterprise Application Architectures by Dr. Indika Kumara

14

Message-Oriented Middleware(MOM)

• An intermediary that enables passing of data and information as self-contained messages between entitles/applications

Application A

Messaging API

Messaging Client

Application B

Messaging API

Messaging ClientMessaging System

Page 15: Enterprise Application Architectures by Dr. Indika Kumara

15

Message-Queuing System

General Architecture of a Message-Queuing System

Page 16: Enterprise Application Architectures by Dr. Indika Kumara

16

Message Broker

General Architecture of a Message Broker

Page 17: Enterprise Application Architectures by Dr. Indika Kumara

17

Messaging Models

• Point-to-Point (1:1)

• Publish-and-Subscribe (1:n)

Page 18: Enterprise Application Architectures by Dr. Indika Kumara

Point to Point Model

18

Customer

JMS Endpoint

OrderQueue

ACKOrderBook()

OrderMsg

Shop Owner

BookService

Page 19: Enterprise Application Architectures by Dr. Indika Kumara

Publish-and-Subscribe Model

19

Customer 1

Enterprise SOATopic

UpdateStatus()

StatusMsg

BookService

Customer n

Page 20: Enterprise Application Architectures by Dr. Indika Kumara

20

Resource-oriented Style

Page 21: Enterprise Application Architectures by Dr. Indika Kumara

21

Resource-oriented Style

• Structure an application as an inter-linked web of resources and resource representations.

• REpresentational State Transfer (REST) is the de facto standard resource-oriented style.– Web (distributed hypermedia system)– REFTful Web services

Page 22: Enterprise Application Architectures by Dr. Indika Kumara

22

REST (REpresentational State Transfer) An architecture style for distributed hypermedia systems

Components : Origin server, proxy, user agent,… Connectors : Client-side API, server-side API, … Data element : Resource, resource identifier, resource

representation, representation meta-data, resource meta-data, control data

Topology: multi-client/multi-server with immediate proxies Constraints: A set of REST principles

ClientOrigin Server

http

Connectors

Resources

Page 23: Enterprise Application Architectures by Dr. Indika Kumara

23

REST : Illustration

Web

Clie

nt

Web

Ser

ver

Book TableGET /book/2Accept : video/mp4

Why Nations Fail

Guns, Germs, and Steel…………..

GET /booksAccept : text/html

Page 24: Enterprise Application Architectures by Dr. Indika Kumara

24

REST …

1) Resource abstraction A concept with an identity (a well-formed

URI)E.g., word document, database record,

object representing human being, image, service, and a collection of other resources

Resources are nouns

Page 25: Enterprise Application Architectures by Dr. Indika Kumara

25

REST …2) Resource representations

A Book (Database Raw)

XMLJSON

Application/xmlApplication/json

Media type (MIME types or content type)

Links

Page 26: Enterprise Application Architectures by Dr. Indika Kumara

REST …

26

3) Messaging– HTTP Request

– 4 Main Verbs (operations on resources)• POST (Create), GET (Retrieve), PUT (Update), and DELETE (Delete)• Safety - do not modify resource representation– GET

• Idempotency - the same result for repeated calls of the same operation– GET, PUT, and DELETE

Page 27: Enterprise Application Architectures by Dr. Indika Kumara

REST …

27

– HTTP request example

Page 28: Enterprise Application Architectures by Dr. Indika Kumara

REST …

28

– HTTP Response

– Types of Response codes• 1xx Informational (e.g., 100 Continue)• 2xx Success (e.g., 200 OK)• 3xx Redirection (e.g., 301 Moved Permanently)• 4xx Client Error (e.g., 404 Not Found)• 5xx Server Error (e.g.,500 Internal Server Error)

Page 29: Enterprise Application Architectures by Dr. Indika Kumara

REST …

29

– HTTP response example

Page 30: Enterprise Application Architectures by Dr. Indika Kumara

REST …

(4) Uniform Interface• Object-Orientation

• Resource-Orientation

30

ReadBook()OrderBook()RateBook()…

GetCustomerName()GetCustomerAddress()UpdateCustomerName()….

Book Object Customer Object

GetPutPostDelete

GetPutPostDelete

Each resource has a unique URL, e.g., http://......../books/1

Order Resource

GetPutPostDeleteRatingResource

GetPutPostDelete

CustomerResource

GetPutPostDeleteAddressResource

Book Resource

Page 31: Enterprise Application Architectures by Dr. Indika Kumara

31

REST …5) Context-free Interactions– Server can understand and process each request

based only on the information in the request.• Server does not keep client session states (but may keep

any other states such as resource states)

LoadBalancerClient

Add a Book to Shopping Cart

Checkout Cart

Session Affinity

Session Statelessness

Web

Ser

vers

Page 32: Enterprise Application Architectures by Dr. Indika Kumara

REST …

6) Use of Intermediaries – To achieve the capabilities such as caching,

filtering, security, content inspection and manipulation, load balancing, etc.

32

ClientA

LoadBalancer

Cache

ClientB

Control data (HTTP Headers) can dictate the behaviors of these intermediaries

Cache-Control: max-age=300

Page 33: Enterprise Application Architectures by Dr. Indika Kumara

33

REST ….7) HATEOAS - Hypertext As The Engine Of Application State– Hypertext links to reference user state/application

state and resources (provided by the server)• Provide => what we can do next, and the URI of

the resource we need to manipulate to do it. • Drive the process flow/workflow

GET http://.../orders => links to order resources and allowed HTTP operations on them => click those links (update, get, delete, etc.) of orders => …

Page 34: Enterprise Application Architectures by Dr. Indika Kumara

34

Event-oriented Style (Event-Driven Architecture)

Page 35: Enterprise Application Architectures by Dr. Indika Kumara

Event-Driven Architecture

35

Event Source

Event Source

Event Channel

Event Sink

Event Sink

E1 E1

E1 E1E1

Produce

Services, Sensors, Email Client, IoT Device, etc.

Transfer, Process

Sense, ConsumeProcess, Respond

TCP, sensor network, content-based pub-sub, ESB, etc.

Business Processes, IoT Devices, Bank Server,…

Page 36: Enterprise Application Architectures by Dr. Indika Kumara

What is an Event?

36

• An occurrence of a significant action/situation , or a significant change in state

• Simple Event

• Complex Event– Temporal, Causal, and Spatial

Incorrect PIN On-Loan

Incorrect PIN Incorrect PIN Incorrect PINPotential

False Identity

Ordered Paid ShippedCase

Completed

Fire Detected Trigger Fire Alarm

After 10 seconds

No Sprinkler Activated

Page 37: Enterprise Application Architectures by Dr. Indika Kumara

Event Processing styles …

37

• Simple Event Processing

• Stream Event Processing

rule "Towing" when $e1 : Event("eTowReqd") then … ExecuteService(“Tow”,msg);end

Event-Condition-Action (ECA) Rules

Rule EnginesJBoss DroolsJess

E1

E1

E1

E1 E1

E1

E1E1

E1

E1

E1

Que

ry

Esper

Select symbol, avg(price) as averagePrice from StockTickEvent.win:length (100)Group by symbol

Page 38: Enterprise Application Architectures by Dr. Indika Kumara

Event Processing styles …

38

• Complex Event Processingrule "Delayed Shipping"when $e1 : BookOrdered( ) not ( BookShipped ( this after [0,7d] $e1 ) )then // inform the customer service // make 5% discountend

rule "Add a new fast service in case response time increases above threshold"when Number ( doubleValue > 100s ) from accumulate ( PerformanceMeasurements ( $rTime : responseTime ) over window:time ( 10m ), average ( $rTime ) )then // add a new service with higher response timeend

better

Page 39: Enterprise Application Architectures by Dr. Indika Kumara

39

Event-Driven Publish/SubscribeProducer/Announcer

Consumer/Listener Consumer/Listener

Medium/Event Manger

Subscribe

Publish

Notify

Page 40: Enterprise Application Architectures by Dr. Indika Kumara

40

Service-oriented Architecture

Page 41: Enterprise Application Architectures by Dr. Indika Kumara

41

SOA (Service-Oriented Architecture)• Services– A discrete unit of functionality that can be accessed remotely

and acted upon and updated independently (wikipedia).– Services generally have published and discoverable

interfaces.– A service can encapsulate different types of entities.

• E.g., business capabilities, database, application, IoT device, …

• SOA– An architectural style that decomposes a software

application into a set of interacting, loosely coupled services and end-users.

Page 42: Enterprise Application Architectures by Dr. Indika Kumara

42

Basic SOA: Concepts

Service Provider

Service Registry

Find

BindPublish

Service Client

Service Description

Service

Service Description

• Alternative heterogeneous services• Dynamic finding and binding (loosely coupled)• Message-oriented communication

Page 43: Enterprise Application Architectures by Dr. Indika Kumara

43

Basic SOA: ExampleBook Publisher1

WSDL_1

WSDL_2

WSDL_3

Book Publisher3

Publish

WSO2 Service Registry

WSDL_1

WSDL_2

WSDL_3

E-book Shop

Book Publisher2

Find

Bind

Page 44: Enterprise Application Architectures by Dr. Indika Kumara

44

What is a Service? …• Service Interface & Implementation

Implementation

Interface

What does it do?

How to use?

Where can I find it?

How to publish it ?Where to host it?

How to represent it ?

How to build it ?

Client Perspective Provider PerspectiveFrom Swinburne Lecture Notes

Page 45: Enterprise Application Architectures by Dr. Indika Kumara

45

What is a Service?• Functional properties– Overall behavior – operations and their control

relationships– E.g., SearchBook, PlaceOrder, CheckOrderStatus,

ShipBook operations of a book publisher service• Non-functional properties– Quality attributes– E.g., An book order must be fulfilled within one week

(response time).

Page 46: Enterprise Application Architectures by Dr. Indika Kumara

46

What is a Service? …• Type of services– Simple services• Request-response nature and fine-grained• E.g., weather reporting, credit card payment , currency

converter– Complex services • Compose and coordinate multiple services, and coarse-

grained• E.g., a service encapsulating buying book process

– Business services, utility services, computational services, data services, …

Page 47: Enterprise Application Architectures by Dr. Indika Kumara

47

Extended SOA : Concepts

CapabilityInterfaceBehavior

DiscoverySelectionBinding

Publication

CoordinationConformanceTransactions

MetricsState management

Load balancingChange management

Description & Basic Operations

Composition

Management and Monitoring

Service provider

Service client

Service Operator

Service aggregator

SemanticsQoS

Page 48: Enterprise Application Architectures by Dr. Indika Kumara

Extended SOA: Example

48

Shipment Service

Inventory Service

BillingService

Credit Card Service

WSO2 BPS WSO2 ESBWSO2 Service Registry

Monitoring, Management, and Policy

Composition

Page 49: Enterprise Application Architectures by Dr. Indika Kumara

49

SOA Architecture Style: Summary• Components

– Service providers– Service consumers– Service registry– ESB (Enterprise Service Bus)– Orchestration server– Management plane– …

• Connectors– SOAP connector– REST connector– JMS (Java Messaging Service) connector– …

Page 50: Enterprise Application Architectures by Dr. Indika Kumara

50

How to Implement SOA?

• Web services is the main approach to implement SOA-based applications.

1) REST –based (representational state transfer) RESTFul Services(Resource-oriented style)

2) WS-* –based SOAP Services (Message-oriented style, Method-oriented style, Event-oriented style )

Page 51: Enterprise Application Architectures by Dr. Indika Kumara

51

WS-* : Web Services Stack / SOAP Services

• A set of open standards and the associated middleware-based solutions • Service description

– WSDL – Web Service Definition Language• Publication and Discovery

– UDDI – Universal Description, Discovery, and Integration. • Message

– SOAP – Simple Object Access Protocol– XML – EXtensible Markup Language

• Transport– HTTP – Hypertext Transfer Protocol – JMS – Java Message Service – SMTP – Simple Mail Transfer Protocol

Page 52: Enterprise Application Architectures by Dr. Indika Kumara

52

WS-* : Web Services Stack …

• Quality of Service– Security – WS-Security– Reliability – WS-ReliableMessaging– …

• Service Policy– WS-Policy

• Business Processes and Service Compositions – BPEL - Business Process Execution Language– WS-CDL - Web Services Choreography Description Language– Custom ESB (enterprise service bus) Languages

Page 53: Enterprise Application Architectures by Dr. Indika Kumara

53

WS-* : Web Services Stack …

From Swinburne lecture notes

Page 54: Enterprise Application Architectures by Dr. Indika Kumara

54

ESB (Enterprise Service Bus)

Page 55: Enterprise Application Architectures by Dr. Indika Kumara

Enterprise Application Integration (EAI)

55

• Point-to-Point

• Hub-and-Spoke

HUB

Applications/Services

• Complex • Tight coupling• Difficult to

understand, maintain/change

• Central control• Loose coupling

Routing, transformation, etc

How to scale? => Federated Hub

Page 56: Enterprise Application Architectures by Dr. Indika Kumara

ESB – Enterprise Service Bus

56

Distributed

ESB services/ESB endpoints (Virtual services)

Mes

sage

Bus

Page 57: Enterprise Application Architectures by Dr. Indika Kumara

ESB …

57

• Can implement complex EAI patterns – Splitter, Aggregator, ...– http://www.enterpriseintegrationpatterns.com/

• An Infrastructure for realizing SOA– Service virtualization– Service interaction mediation– Service discovery, monitoring, and management – Service QoS (Quality of Services)• Secure Messaging• Reliable Messaging• …

Page 58: Enterprise Application Architectures by Dr. Indika Kumara

58

Business Processes and Service Compositions

Page 59: Enterprise Application Architectures by Dr. Indika Kumara

Business Processes

59

• Ordered set of tasks/activities to achieve (a) specific (business) objective

UserBook

Inventory

GoogleBook

Amazon

RequestNewBoook

Start

CheckBookAvailability

Available?

RejectOrder AssessBookQuality

Quality?

Yes No

PlaceOrder

Bad

GoodEnd

Notify

Service Composition

SOA => Flexible, Dynamic Processes

Page 60: Enterprise Application Architectures by Dr. Indika Kumara

Types of Processes

60

UserBook

Inventory

GoogleBook

Amazon

Coordination of

Tasks from

Composer View

Orchestration • BPEL• BPMN

Centralized Approach

Page 61: Enterprise Application Architectures by Dr. Indika Kumara

Types of Processes …

61

User

Book Inventory

GoogleBook

Amazon

Choreography WS-CDL

• Global View of Externally Visible Interactions

• Decentralized approach

BuyBook

CheckQualitySearchBook

BuyB

ook

FindPublishers

Page 62: Enterprise Application Architectures by Dr. Indika Kumara

Types of Processes …• Artefact-centric

• Restful (HATEOAS - Hypertext As The Engine Of Application State)

62

Created QualityChecked Ordered Completed

Order Artefact

/books /books/1/books/2

/books/2/order/payment/.../accounts/435/debit

Bank Service

Book Inventory Service

/books/2/order/books/2/rating

Page 63: Enterprise Application Architectures by Dr. Indika Kumara

63

Topics Covered (Briefly)• Enterprise Applications/Computing• Architecture Styles for Enterprise Applications

– Method-oriented– Message-oriented– Resource-oriented

• REST (representational state transfer)– Event-oriented

• SOA (service-oriented architecture)– Basic and extended SOA– Implementing SOA

• RESTful • WS-* (web services stack)

– ESB (enterprise service bus)• Business processes and service compositions

Page 64: Enterprise Application Architectures by Dr. Indika Kumara

64

Page 65: Enterprise Application Architectures by Dr. Indika Kumara

65

References• COS80011 (Web Application Architectures), Swinburne University of

Technology • http://www.ibm.com/developerworks/library/ws-appint/• Papazoglou, Michael. Web services: principles and technology. Pearson

Education, 2008.• https://www.ibm.com/developerworks/library/ws-whichwsdl/• Michael P. Papazoglou, Paolo Traverso, Schahram Dustdar, and Frank

Leymann. 2007. Service-Oriented Computing: State of the Art and Research Challenges. Computer 40, 11 (November 2007), 38-45.

• Len Bass, Paul Clements, and Rick Kazman. 2013. Software Architecture in Practice (3 ed.). Pearson Education, Inc., USA.

• Roy Thomas Fielding. Architectural styles and the design of network-based software architectures. Diss. University of California, Irvine, 2000.

• Nicolai Josuttis. 2007. Soa in Practice: The Art of Distributed System Design. O'Reilly Media, Inc..