enterprise integration patterns 2: the making of a pattern ... · enterprise integration patterns...

24
Software Architecture Summit Enterprise Integration Patterns © 2015 Gregor Hohpe, www.eaipatterns.com Enterprise Integration Patterns 2: The Making of a Pattern Language Gregor Hohpe Chief Architect, Allianz SE www.EnterpriseIntegrationPatterns.com leanpub.com/37things @ghohpe www.EnterpriseIntegrationPatterns.com © 2017 Gregor Hohpe Asynchronous Messaging Style Channels have logical, location-independent addresses Systems send messages Placing a message into the Channel is quick (“fire-and- forget”). The Channel queues messages until the receiving application is ready to consume. Simplified Interaction Temporal Decoupling Location Decoupling An "honest" architectural style that does not try to deny the limitations of the underlying medium. 2 Receiver Sender Message Channel (Queue)

Upload: phamnhi

Post on 16-May-2018

228 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Enterprise Integration Patterns 2: The Making of a Pattern ... · Enterprise Integration Patterns 2: ... Manage and Test the ... Software Architecture Summit Enterprise Integration

Software Architecture Summit Enterprise Integration Patterns

© 2015 Gregor Hohpe, www.eaipatterns.com

Enterprise Integration Patterns 2:

The Making of a Pattern Language

Gregor HohpeChief Architect, Allianz SE

www.EnterpriseIntegrationPatterns.com

leanpub.com/37things

@ghohpe

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Asynchronous Messaging Style

Channels have logical, location-independent

addresses

Systems send messages

Placing a message into the Channel is quick (“fire-and-

forget”). The Channel queues messages until the

receiving application is ready to consume.

Simplified

Interaction

Temporal

Decoupling

Location

Decoupling

An "honest" architectural style that does not try to deny

the limitations of the underlying medium.

2

ReceiverSender

Message

Channel

(Queue)

Page 2: Enterprise Integration Patterns 2: The Making of a Pattern ... · Enterprise Integration Patterns 2: ... Manage and Test the ... Software Architecture Summit Enterprise Integration

Software Architecture Summit Enterprise Integration Patterns

© 2015 Gregor Hohpe, www.eaipatterns.com

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Asynchronous Architectural Style

3

Web SiteNew Order

Order Mgmt

Inventory

Shipping

Confirm

Web SiteNew Order

Order Mgmt

Inventory

Shipping

Ack

Ack

New Order

Synchronous(Call Stack)

Asynchronous(Pipeline, Itinerary)

Idle

Ack

New Order

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Asynchronous Messaging Benefits

Temporal decoupling

• Sender does not have to wait for receiver to process message

Limit Failure Propagation

• Sender not affected by intermittent failure

• Can be reliable over unreliable transports

Throttling

• Receiver can consume messages at its own pace

• Processing units can be tuned independently

Insertion of intermediaries (Pipes-and-Filters)

• Composability: Transformation, routing etc.

Throughput over latency

• “Wider bridges not faster cars”

4

Page 3: Enterprise Integration Patterns 2: The Making of a Pattern ... · Enterprise Integration Patterns 2: ... Manage and Test the ... Software Architecture Summit Enterprise Integration

Software Architecture Summit Enterprise Integration Patterns

© 2015 Gregor Hohpe, www.eaipatterns.com

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Messaging Systems

1. Transport messages ApplicationApplication

2. Design messages

3. Route the message to

the proper destination

Application

4. Transform the message

to the required format

5. Produce and consume

messages

ApplicationApplication

Application

6. Manage and Test the

System

5

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Messaging Systems

1. Transport messages

3. Route the message to

the proper destination

4. Transform the message

to the required format

5. Produce and consume

messages

6. Manage and Test the

System

Channel Patterns

Routing Patterns

Transformation Patterns

Endpoint Patterns

Management Patterns

2. Design messages Message Patterns

Application

6

Page 4: Enterprise Integration Patterns 2: The Making of a Pattern ... · Enterprise Integration Patterns 2: ... Manage and Test the ... Software Architecture Summit Enterprise Integration

Software Architecture Summit Enterprise Integration Patterns

© 2015 Gregor Hohpe, www.eaipatterns.com

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Enterprise Integration Patterns

7

185,000 Words

700 pages

70,000 copies

English

Russian

Chinese

Korean

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Patterns in Google Cloud Pub-Sub

Cloud

Pub/Sub

Publisher

C

Publisher

B

Topic CTopic B

Subscription YC

Subscriber

Y

Subscriber

Z

Subscription ZC

Message 3

Message 3 Message 3

Subscription B

Message 2

Subscriber

B1

Subscriber

B2

Message 2

Publish-SubscribePoint-to-Point

Publish-Subscribe

Channel

Competing

ConsumersMessage

Expiration

Durable

Subscriber Polling

Consumer

Transactional

Client

8

Page 5: Enterprise Integration Patterns 2: The Making of a Pattern ... · Enterprise Integration Patterns 2: ... Manage and Test the ... Software Architecture Summit Enterprise Integration

Software Architecture Summit Enterprise Integration Patterns

© 2015 Gregor Hohpe, www.eaipatterns.com

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Serverless Content-based Router

10

const Pubsub = require('@google-cloud/pubsub'); const pubsub = Pubsub({projectId: "eaipubsub"})

exports.contentBasedRouter = function contentBasedRouter(event) {const pubsubMessage = event.data;const payload = Buffer.from(pubsubMessage.data, 'base64').toString();

order = JSON.parse(payload) outChannel = getOutChannel(order.type); return pubsub.topic(outChannel).get({autoCreate: true}).then(function(data) { var topic = data[0]; return topic.publish(order);

}) };

function getOutChannel(type) {switch(type) { case "widget": return "widgets"; case "gadget": return "gadgets"; default: return "unknown";

} }

http://www.enterpriseintegrationpatterns.com/ramblings/google_cloud_functions.html

gcloud beta functions deploy contentBasedRouter --stage-bucket eaipubsub-functions --trigger-topic orders

Conversations

11

Page 6: Enterprise Integration Patterns 2: The Making of a Pattern ... · Enterprise Integration Patterns 2: ... Manage and Test the ... Software Architecture Summit Enterprise Integration

Software Architecture Summit Enterprise Integration Patterns

© 2015 Gregor Hohpe, www.eaipatterns.com

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Messaging and Conversations

12

Conversation PatternsMessaging Patterns

• Focus on message

• Follows the message

• One-way

• Deals with transport

• “Stateless”

• Focus on participants

• Follows time

• Two- / multi-way

• Deals with resources

• “Stateful”

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Conversation State and Endpoint State

• Legal message sequences defined through

the protocol

• Each conversation instance has a state

• Each participant has a (potentially different)

process definition

• Local process state maps to conversation

state

13

Order

Invoice

Payment

Drinks

Conversation

State

Internal State:

Processing

Payment

Internal State:

Waiting for

Payment

Internal State:

Making Drinks

Page 7: Enterprise Integration Patterns 2: The Making of a Pattern ... · Enterprise Integration Patterns 2: ... Manage and Test the ... Software Architecture Summit Enterprise Integration

Software Architecture Summit Enterprise Integration Patterns

© 2015 Gregor Hohpe, www.eaipatterns.com

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Subscriptions

14

Publish-Subscribe Channel Subscribe-Notify

PublisherSubscriber

Subscriber

Subscriber

Subscribe

Notify

Notify

Notify

Subscriber Provider

How can the sender broadcast an

event to all interested receivers?

How can one participant receive

information from another participant if

that information cannot easily be

packaged into a single message?

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Conversation Design & Challenges

Protocol design:

• Completeness

• Deadlocks

• Error States

• Map conversation state to

participant state

Visualization:

• Difficult to represent state space

• Hard to capture the essence in an

evocative “sketch”

• UML 2 difficult to decipher

• BPMN2 suitable, but visually

verbose

15

• Participant Roles

• Message Type

• Protocol

Challenges:

Conversation Design:

Page 8: Enterprise Integration Patterns 2: The Making of a Pattern ... · Enterprise Integration Patterns 2: ... Manage and Test the ... Software Architecture Summit Enterprise Integration

Software Architecture Summit Enterprise Integration Patterns

© 2015 Gregor Hohpe, www.eaipatterns.com

Patterns &

Pattern

Languages

16

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Christopher Alexander: A Patterns Language

BED ALCOVE

Design problem

Bedrooms make no sense.

Forces

First, the bed in a bedroom creates awkward

spaces around it: dressing, working, watching television,

sitting, are all rather foreign to the side spaces left over

around a bed. (...)

Second, the bed itself seems more comfortable in a space

that is adjusted to it.

Solution

Don't put single beds in empty rooms called bedrooms, but

instead put individual bed alcoves off rooms with other

nonsleeping functions, so the bed itself becomes a tiny private

haven.

Related Patterns

Communal Sleeping, Marriage Bed

Ceiling Height Variety, Half-open Room, Thick Walls

17

Page 9: Enterprise Integration Patterns 2: The Making of a Pattern ... · Enterprise Integration Patterns 2: ... Manage and Test the ... Software Architecture Summit Enterprise Integration

Software Architecture Summit Enterprise Integration Patterns

© 2015 Gregor Hohpe, www.eaipatterns.com

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Patterns Revisited

• A good solution to a problem within a

specific context?

• Recurrence (relevant)

• Teaching (“why” and “how”)

• Name (forms a language)

• “Chicken Mc Nuggets of Information” (Ward Cunningham)

• Human-to-human communication

• Harvested: observed from actual experience

18

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Pattern Relationships

19

Design Pattern

Space

Page 10: Enterprise Integration Patterns 2: The Making of a Pattern ... · Enterprise Integration Patterns 2: ... Manage and Test the ... Software Architecture Summit Enterprise Integration

Software Architecture Summit Enterprise Integration Patterns

© 2015 Gregor Hohpe, www.eaipatterns.com

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Pattern Relationships

20

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Pattern Sequence

21

“The patterns are ordered, beginning with the

very largest, for regions and towns, the working

down through neighborhoods, clusters of

buildings, buildings, rooms and alcoves, ending

finally with details of construction.

This order, which is presented as a straight

linear sequence, it essential to the way the

language works.”

21 3 4 5 … 253

Page 11: Enterprise Integration Patterns 2: The Making of a Pattern ... · Enterprise Integration Patterns 2: ... Manage and Test the ... Software Architecture Summit Enterprise Integration

Software Architecture Summit Enterprise Integration Patterns

© 2015 Gregor Hohpe, www.eaipatterns.com

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Towards Pattern Languages

• Pattern Complements

• Competition

• Cooperation

• Combination

• Pattern Compounds

• Pattern Sequences

• Pattern Collections

• Level, Domain, Intent

22

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Pattern Language: Message Flow

23

Page 12: Enterprise Integration Patterns 2: The Making of a Pattern ... · Enterprise Integration Patterns 2: ... Manage and Test the ... Software Architecture Summit Enterprise Integration

Software Architecture Summit Enterprise Integration Patterns

© 2015 Gregor Hohpe, www.eaipatterns.com

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Pattern Story: Root Patterns

24

MessagingIntegration

Styles

Messaging

SystemsMessage

Message

Channel

Pipes and

Filters

Message

Router

Message

Translator

Message

Endpoint

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Pattern Competition: Routing Patterns

25

Content-Based Router

Message Filter

Recipient List

Splitter

Aggregator

Resequencer

Compos. Msg. Processor

Scatter-Gather

Routing Slip

Process Manager

Simple

Composed Parallel

Sequential

Split Message

Broadcast Message

Predetermined, Linear

Any Path

Process one msg at a

time (stateless)

Process multiple

msgs at a time (stateful)

Less msgs out

Same number

of msgs out

Exactly One

Zero or One

Parallel

Sequential

Single msg out

Mult. msgs out

Page 13: Enterprise Integration Patterns 2: The Making of a Pattern ... · Enterprise Integration Patterns 2: ... Manage and Test the ... Software Architecture Summit Enterprise Integration

Software Architecture Summit Enterprise Integration Patterns

© 2015 Gregor Hohpe, www.eaipatterns.com

Conversation

Patterns

26

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Conversation Pattern Language

27

Discovery

Setting Up

?

!

Initiation

Resource Mgmt.

Application-level

✓ ✓

Ensuring Consistency

Basic Conversations

Participants

Intermediaries

Page 14: Enterprise Integration Patterns 2: The Making of a Pattern ... · Enterprise Integration Patterns 2: ... Manage and Test the ... Software Architecture Summit Enterprise Integration

Software Architecture Summit Enterprise Integration Patterns

© 2015 Gregor Hohpe, www.eaipatterns.com

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Conversation Pattern Language

28

?

!✓ ✓

Discovery Basic Conversations Resource Management

• Dynamic Discovery

• Advertise Availability

• Consult Directory

• Referral

• Leader Election

• Fire-and-Forget

• Asynchronous Req-Resp

• Req-Resp with Retry

• Polling

• Subscribe-Notify

• Quick Acknowledgment

• Incremental State

• Lease

• Renewal reminder

Initiation Intermediaries Ensuring Consistency

• Three-way Handshake

• Acquire Token First

• Rotate Tokens

• Verify Identity

• User Grants Access

• Proxy

• Relay

• Load Balancer

• Scatter Gather

• Ignore Error

• Compensating Action

• Tentative Operation

• Coordinated Agreement

Discovery

29

Page 15: Enterprise Integration Patterns 2: The Making of a Pattern ... · Enterprise Integration Patterns 2: ... Manage and Test the ... Software Architecture Summit Enterprise Integration

Software Architecture Summit Enterprise Integration Patterns

© 2015 Gregor Hohpe, www.eaipatterns.com

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Discovery Considerations

30

• Division of responsibility between

provider and consumer

• Arrival/departure rate

• Arriving/departing providers

• Arriving/departing consumers

• Centralized vs. Distributed

• Is there an element dedicated

to discovery?

• Addressability

• What’s the result of discovery?

• Trust

• Is the consumer happy with just

any provider?

C

P1

P2

?

• Matching

• Unique Identifiers

• Interface Definition / Type

• Attributes

• Keyword match (search)

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Point-to-point communication requires knowledge of the conversation

partner (or channel).

Central services for discovery are bound to get out of sync with reality.

Centralized administration may result in a single point of failure.

Even in the presence of a central lookup service, a new participant has to

first establish a connection to the lookup service.

How can a conversation initiator

find a partner when it has no

knowledge whatsoever about

available partners?

31

Page 16: Enterprise Integration Patterns 2: The Making of a Pattern ... · Enterprise Integration Patterns 2: ... Manage and Test the ... Software Architecture Summit Enterprise Integration

Software Architecture Summit Enterprise Integration Patterns

© 2015 Gregor Hohpe, www.eaipatterns.com

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Dynamic Discovery

1. Broadcast Lookup request

2. Interested providers send Available responses

3. Requestor initiates interaction with chosen provider

Examples: DHCP

Lookup (Broadcast)

Message

Available

Available

Initiator Providers

32

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Dynamic Discovery can flood the network with requests.

The number of available providers is often small compared to the number

of conversations.

How can a participant let others know

that it is available?

33

Page 17: Enterprise Integration Patterns 2: The Making of a Pattern ... · Enterprise Integration Patterns 2: ... Manage and Test the ... Software Architecture Summit Enterprise Integration

Software Architecture Summit Enterprise Integration Patterns

© 2015 Gregor Hohpe, www.eaipatterns.com

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Advertise Availability

Available participants broadcast their existence and capabilities

Examples: Wi-Fi

Message

Initiator Providers

Available (Broadcast)

Available (Broadcast)

Available (Broadcast)

Available (Broadcast)

34

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Many networks do not route broadcast packets beyond the local

network.

Centralized administration is often needed or desired in setting up

a new service.

How can a conversation initiator find a

partner across a large network without

flooding the network with requests?

35

Page 18: Enterprise Integration Patterns 2: The Making of a Pattern ... · Enterprise Integration Patterns 2: ... Manage and Test the ... Software Architecture Summit Enterprise Integration

Software Architecture Summit Enterprise Integration Patterns

© 2015 Gregor Hohpe, www.eaipatterns.com

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Consult Directory

Directory answers request for conversation partner.

Requires addressability, i.e. to embed addresses in messages

Directory may store additional metadata about the service

May use Dynamic Discovery to find the Directory

Example: UDDI Directory, DNS

Message

Initiator Registry Providers

Lookup

Reference

Register

Register

36

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

A participant may be required to interact with the same partner that

another participant is already interacting with.

Directories are generally context free, i.e. they do not keep track of

existing conversations and when assigning an initiator to a partner.

Some participants may not want to be "discovered". However, "friends of

friends" are allowed to interact with them.

The choice of conversation partner may

depend on the context of a conversation or

may change over time.

How can an initiator discover the right

conversation partner?

37

Page 19: Enterprise Integration Patterns 2: The Making of a Pattern ... · Enterprise Integration Patterns 2: ... Manage and Test the ... Software Architecture Summit Enterprise Integration

Software Architecture Summit Enterprise Integration Patterns

© 2015 Gregor Hohpe, www.eaipatterns.com

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Referral

One participant passes a reference to another participant.

Consult Directory is a specialized case of Referral

Example: HTTP 302

Request

Message

Referral

Initiator Referrer Referral

38

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Referral

Advertise Availability Consult Directory

Dynamic Discovery

Pattern Language: Discovery

39

No Intermediary Intermediary

Consumer-

driven

Provider

driven

Page 20: Enterprise Integration Patterns 2: The Making of a Pattern ... · Enterprise Integration Patterns 2: ... Manage and Test the ... Software Architecture Summit Enterprise Integration

Software Architecture Summit Enterprise Integration Patterns

© 2015 Gregor Hohpe, www.eaipatterns.com

Intermediaries

40

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Multi-Party Conversations: Intermediaries

41

Intermediaries Connectors

CoordinatorsPeer-to-peer

Page 21: Enterprise Integration Patterns 2: The Making of a Pattern ... · Enterprise Integration Patterns 2: ... Manage and Test the ... Software Architecture Summit Enterprise Integration

Software Architecture Summit Enterprise Integration Patterns

© 2015 Gregor Hohpe, www.eaipatterns.com

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Proxy

How can a participant communicate with a partner that is not

visible or not reachable?

Initiator can hide identity using a Proxy

Proxy can monitor conversations

Proxy may need to be stateful for two-way conversations

Proxy can become a bottleneck

Message

Message

Initiator Proxy

Message

Message

Partner

42

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Relay

How can participants engage in a two-way communication when

each participant is limited to outbound requests?

High overhead when using Polling

All other conversations can be layer on top of Relay

Needs to be stateful

Example: Amazon SQS

Message

Initiator Relay

Inquiry

Message

Partner

43

Page 22: Enterprise Integration Patterns 2: The Making of a Pattern ... · Enterprise Integration Patterns 2: ... Manage and Test the ... Software Architecture Summit Enterprise Integration

Software Architecture Summit Enterprise Integration Patterns

© 2015 Gregor Hohpe, www.eaipatterns.com

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Scatter-Gather (Aggregator)

How can a participant solicit responses from a number of

participants without connecting to all of them?

Widespread business model, e.g. “Aggregators”

Request

Response

Requestor Scatter-Gather

Request

Response

Providers

Request

Response

44

Composing

Conversations

Page 23: Enterprise Integration Patterns 2: The Making of a Pattern ... · Enterprise Integration Patterns 2: ... Manage and Test the ... Software Architecture Summit Enterprise Integration

Software Architecture Summit Enterprise Integration Patterns

© 2015 Gregor Hohpe, www.eaipatterns.com

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Composing Conversations

49

Sequencing

One conversation follows another.

Expansion

A single message in one

conversation consists of another

conversation.

Overlay

Conversations occur concurrently.

Conclusion

Page 24: Enterprise Integration Patterns 2: The Making of a Pattern ... · Enterprise Integration Patterns 2: ... Manage and Test the ... Software Architecture Summit Enterprise Integration

Software Architecture Summit Enterprise Integration Patterns

© 2015 Gregor Hohpe, www.eaipatterns.com

www.EnterpriseIntegrationPatterns.com© 2017 Gregor Hohpe

Conclusions

• Enterprise Integration is more than messaging

• A Pattern is more than a solution to a recurring problem

• A Pattern Language is more than a set of patterns

51

Conversation Patterns Work-in-Progress

eaipatterns.com/patterns/conversationeaipatterns.com/ramblings

@ghohpe

leanpub.com/37things