14
Asynchronous Messaging Sergey Shishkin http:// shishkin.org source: http://www.flickr.com/photos/joits/1110215271/

Asynchronous Messaging @DNUG Cologne, 07.04.2009

Embed Size (px)

DESCRIPTION

A presentation by Sergey Shishkin on Asynchronous Messaging given on 07.04.2009 at .NET User Group Cologne.

Citation preview

Page 1: Asynchronous Messaging @DNUG Cologne, 07.04.2009

Asynchronous Messaging

Sergey Shishkin

http://shishkin.org

Image source: http://www.flickr.com/photos/joits/1110215271/

Page 2: Asynchronous Messaging @DNUG Cologne, 07.04.2009

AgendaAgenda

Why Messaging?– And what’s wrong with good old RPC?

Sample scenario– News module of the Prism’s StockTrader RI

Under the hood of Message Bus– Building a Message Bus in 37 lines of code– And what those 37 lines did not cover?

Image source: http://www.flickr.com/photos/mychatham/206928250/

Page 3: Asynchronous Messaging @DNUG Cologne, 07.04.2009

Communication Styles

Remote Procedure Calls–Synchronous–High coupling

One-Way Messages–Asynchronous–Loose coupling

Page 4: Asynchronous Messaging @DNUG Cologne, 07.04.2009

Fallacies of Distributed Computing*Fallacies of Distributed Computing*

* * http://en.wikipedia.org/wiki/Fallacies_of_Distributed_Computing

1.The network is reliable2.Latency is zero3.Bandwidth is infinite4.The network is secure5.Topology doesn't change6.There is one administrator7.Transport cost is zero8.The network is homogeneous

Image source: http://www.flickr.com/photos/pascalcharest/308357541/

Page 5: Asynchronous Messaging @DNUG Cologne, 07.04.2009

Composite ApplicationsComposite Applications

Image source: http://www.flickr.com/photos/curiouslee/2136283589/

Modularized applications are similar to distributed ones

GUI composition is solved by:•Common region infrastructure•Event-based GUI synchronization

Same pattern in broader context•Common Message Bus infrastructure•Message-based components integration

Page 6: Asynchronous Messaging @DNUG Cologne, 07.04.2009

Tenets of Service-Orientation*

Image source: http://www.flickr.com/photos/hyper-world/2401419260/

Boundaries are explicit

Services are autonomous

Services share schema and contract, not class

Service compatibility is based upon policy

* http://msdn.microsoft.com/en-us/magazine/cc164026.aspx

Page 7: Asynchronous Messaging @DNUG Cologne, 07.04.2009

Messaging Patterns

* http://www.enterpriseintegrationpatterns.com/toc.html

Message Bus is a central place for implementing integration patterns*

Page 8: Asynchronous Messaging @DNUG Cologne, 07.04.2009

Advantages of Messaging (I)

Image source: http://www.flickr.com/photos/renaissancechambara/2288556895/

Loose coupling

Separation of concerns

Orthogonal architecture

Page 9: Asynchronous Messaging @DNUG Cologne, 07.04.2009

Advantages of Messaging (II)

Testing

Scalability

Page 10: Asynchronous Messaging @DNUG Cologne, 07.04.2009

Disadvantages of MessagingDependency tracing•Who is publishing that message?•Is publishing of that message required?

Debugging

•Same as debugging of multithreaded apps

Learning curve•It’s not a new technology, it’s a paradigm shift•Requires different mindset and discipline

Image source: http://www.flickr.com/photos/lwr/2257112719/

Page 11: Asynchronous Messaging @DNUG Cologne, 07.04.2009

Guidelines

Consider messaging to loose coupling

Avoid RPC across modules/business services/bounded contexts*

* In terms of DDD

Image source: http://www.flickr.com/photos/rodneytrotter/3323664794/

Page 12: Asynchronous Messaging @DNUG Cologne, 07.04.2009

Look aheadLook ahead

Messaging is the default communication style for cloud-based services

Silverlight does not support synchronous communication out of the box

Image source: http://www.flickr.com/photos/bestrated1/2441332480/

Page 13: Asynchronous Messaging @DNUG Cologne, 07.04.2009

DEMO

Page 14: Asynchronous Messaging @DNUG Cologne, 07.04.2009

References• Composite WPF guidance aka “Prism”, StockTrader RI

– http://compositewpf.codeplex.com/• StockTrader with messages (revision 12, as shown in demo)

– http://code.google.com/p/messagingwpf/source/browse/trunk/src/StockTraderRI/• Some OSS messaging frameworks

– http://code.google.com/p/masstransit/– http://www.nservicebus.com– https://rhino-tools.svn.sourceforge.net/svnroot/rhino-tools/trunk/esb/

• Fallacies of distributed computing– http://en.wikipedia.org/wiki/Fallacies_of_Distributed_Computing

• Four tenets of service orientation– http://msdn.microsoft.com/en-us/magazine/cc164026.aspx

• Enterprise integration patterns– http://www.enterpriseintegrationpatterns.com/toc.html