Upload
sergey-shishkin
View
1.321
Download
0
Embed Size (px)
DESCRIPTION
A presentation by Sergey Shishkin on Asynchronous Messaging given on 07.04.2009 at .NET User Group Cologne.
Citation preview
Asynchronous Messaging
Sergey Shishkin
http://shishkin.org
Image source: http://www.flickr.com/photos/joits/1110215271/
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/
Communication Styles
Remote Procedure Calls–Synchronous–High coupling
One-Way Messages–Asynchronous–Loose coupling
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/
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
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
Messaging Patterns
* http://www.enterpriseintegrationpatterns.com/toc.html
Message Bus is a central place for implementing integration patterns*
Advantages of Messaging (I)
Image source: http://www.flickr.com/photos/renaissancechambara/2288556895/
Loose coupling
Separation of concerns
Orthogonal architecture
Advantages of Messaging (II)
Testing
Scalability
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/
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/
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/
DEMO
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