32
Messaging Patterns An alternative approach to modeling with ESB’s Jimmy P @pjimmy [email protected] http:// www.blog.thejimmyp.com

Messaging Patterns

  • Upload
    adonai

  • View
    51

  • Download
    0

Embed Size (px)

DESCRIPTION

Messaging Patterns. An alternative approach to modeling with ESB’s. Jimmy P @ pjimmy [email protected] http:// www.blog.thejimmyp.com. Outline. Some Context Some Problems Intro to Messaging Systems Some Solutions And The Focus Some Patterns. Platform. Temporal. Spatial. Afferent. - PowerPoint PPT Presentation

Citation preview

Page 1: Messaging Patterns

Messaging PatternsAn alternative approach to modeling with ESB’s

Jimmy P@[email protected]://www.blog.thejimmyp.com

Page 2: Messaging Patterns

OutlineSome Context

Some Problems Intro to Messaging SystemsSome Solutions

And The FocusSome Patterns

Page 3: Messaging Patterns

Some diagrams adapted from material by Udi Dahan – The Software Simplisthttp://www.udidahan.com

It’s mainly about coupling

Efferent

Afferent

Platform Temporal

Spatial

Page 4: Messaging Patterns

Efferent

Afferent

Platform Temporal

Spatial

• AKA interoperability

• Most RPC and other common messaging technologies are platform

• dependent in painful places

Page 5: Messaging Patterns

Some diagrams adapted from material by Udi Dahan – The Software Simplisthttp://www.udidahan.com

Efferent

Afferent

Platform Temporal

Spatial

• When A calls B synchronously B’s processing time affects A

A BA Calls B

B Returns

A Blocks WhileB Processes

B Processes

Page 6: Messaging Patterns

Some diagrams adapted from material by Udi Dahan – The Software Simplisthttp://www.udidahan.com

Efferent

Afferent

Platform Temporal

Spatial

• Where are the components physically?

• Is there multiple instances, and where are they?

• How do I decide which of multiple logically identical components I should send my message to?

• What happens if the only physical instance I know of is down?

Page 7: Messaging Patterns

Some diagrams adapted from material by Udi Dahan – The Software Simplisthttp://www.udidahan.com

Efferent

Afferent

Platform Temporal

Spatial

• Afferent - What do I take a dependency on?

• Efferent - What takes a dependency on me?

Page 8: Messaging Patterns

But it’s also a little about data loss

Page 9: Messaging Patterns

Slide courtesy of Udi Dahan – The Software Simplist

http://www.udidahan.com

When Servers Crash

DBApp[HTTP] $$ Order

TxCall 1 of 3

Call 2 of 3

Critical Windows Patch

RollbackWhere’s the order!?

Page 10: Messaging Patterns

Slide courtesy of Udi Dahan – The Software Simplist

http://www.udidahan.com

App[HTTP] $$ Order

Tx

When Databases Are Down

Exception

Write to log

DBCall 1 of 3

Down

Where’s the order!?

Page 11: Messaging Patterns

Slide courtesy of Udi Dahan – The Software Simplist

http://www.udidahan.com

TxApp[HTTP] $$ Order

When Deadlocks Happen

DBCall 1 of 3

Deadlock

ExceptionWrite to log A B

Call 2 of 3

Where’s the order!?

Page 12: Messaging Patterns

Slide courtesy of Udi Dahan – The Software Simplist

http://www.udidahan.com

Data Loss Using Web Services

A B C D

WSDB

[HTTP] Invoke

$$ Order

Deadlock

Rollback

Not Rolled back

Page 13: Messaging Patterns

So What is SOA and what are messaging systems?

Page 14: Messaging Patterns

Bus vs. Broker vs. RPC

Service C

Service B

Service A

Broker

.NETWCF

Service

JAVA WEB

Service

SAP

SVC A

BUS

SVC B

BUS

SVC C

BUS

External JSON

ServiceSalesForc

e

Service F

Service C

Service D

Service E

Page 15: Messaging Patterns

What makes up a messaging system

Messages travel between queuesQueues are persistent stores located on the

machine the service is deployed toQueues can persist messages to non volatile

storage in case of faultsAdding and removing messages from queues

can be transactionalQueues provide us with our asynchronous

behavior

Page 16: Messaging Patterns

So How does messaging help with coupling?

Page 17: Messaging Patterns

Some diagrams adapted from material by Udi Dahan – The Software Simplisthttp://www.udidahan.com

Efferent

Afferent

Platform Temporal

Spatial

• XML for message format & XSD for message schema

• Communication protocol and addressing is a problem

Page 18: Messaging Patterns

Some diagrams adapted from material by Udi Dahan – The Software Simplisthttp://www.udidahan.com

Efferent

Afferent

Platform Temporal

Spatial

• Asynchronous messaging

Page 19: Messaging Patterns

Some diagrams adapted from material by Udi Dahan – The Software Simplisthttp://www.udidahan.com

Efferent

Afferent

Platform Temporal

Spatial

• Create logically autonomous services

• Address services logically not physically

Page 20: Messaging Patterns

Some diagrams adapted from material by Udi Dahan – The Software Simplisthttp://www.udidahan.com

Efferent

Afferent

Platform Temporal

Spatial

• Use the message schema to create a level of indirection between services so there is no direct dependency

Service A

Communications Infrastructure

Schema A

Service B

Schema B

Page 21: Messaging Patterns

And with data loss?

Page 22: Messaging Patterns

Slide courtesy of Udi Dahan – The Software Simplist

http://www.udidahan.com

Tx

Messages are transactions

Q$$ Order

App

Receive

DBCall 1 of 3

Rollback

Call 2 of 3

Rollback

The order is back in the queue

Page 23: Messaging Patterns

Slide courtesy of Udi Dahan – The Software Simplist

http://www.udidahan.com

Web Services with Messaging

MessagingGateway

A B C D

WS

Msg

DB

$$ Order

[HTTP] Invoke

The message won’t be sent if there’s a failure

Page 24: Messaging Patterns

So messaging is the silver bullet ;)

Let’s look at some patterns

Page 25: Messaging Patterns

Return Address Pattern

Provides a place to specify a physical address per message, allowing of logical addressing per message type

Now EndpointA can do other work while waiting for it’s response

Page 26: Messaging Patterns

Load Balancing with Return Address

EndpointA can specify an endpoint under less load to process the response if it has that information

Page 27: Messaging Patterns

Correlated Request/Response

An extension of Return AddressAllows services to maintain state

Page 28: Messaging Patterns

Multiple Responses with Correlated

Request/Response

User may not know or care about ALL of the responses

Page 29: Messaging Patterns

Ultimate in SRP

Multiple Handlers with Correlated

Request/Response

Page 30: Messaging Patterns

Publish/Subscribe

Allows us to add Events to our modeling arsenal By subscribing to message types from a logical address we are

only coupled to schema This allows us to trivially increase parallelism as required

Page 31: Messaging Patterns

Simpler more Robust systems

Modeling Business with Messaging Systems

Page 32: Messaging Patterns

Resources and Thankshttp://www.nservicebus.com/[email protected]@[email protected] If you are really keen watch this space

http://www.udidahan.com/training/ a truly life changing course

And many thanks to Udi for letting me steal his pretty animated slides and a diagram here and there. Made me look better than I deserved and saved me heaps of work