<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Scott M. Felder &#187; NServiceBus</title>
	<atom:link href="http://blog.scottmfelder.com/tag/nservicebus/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.scottmfelder.com</link>
	<description>Hello Event-Driven World!</description>
	<lastBuildDate>Tue, 23 Aug 2011 05:18:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.scottmfelder.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/8eb89b06f44fe4fb33cabdfa15c170e9?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Scott M. Felder &#187; NServiceBus</title>
		<link>http://blog.scottmfelder.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.scottmfelder.com/osd.xml" title="Scott M. Felder" />
	<atom:link rel='hub' href='http://blog.scottmfelder.com/?pushpress=hub'/>
		<item>
		<title>Event Driven SOA with NServiceBus</title>
		<link>http://blog.scottmfelder.com/2009/11/04/event-driven-soa-with-nservicebus/</link>
		<comments>http://blog.scottmfelder.com/2009/11/04/event-driven-soa-with-nservicebus/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 21:52:19 +0000</pubDate>
		<dc:creator>Scott Felder</dc:creator>
				<category><![CDATA[Alt .Net]]></category>
		<category><![CDATA[DDD]]></category>
		<category><![CDATA[EDA]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Event-Driven SOA]]></category>

		<guid isPermaLink="false">http://blog.scottmfelder.com/?p=22</guid>
		<description><![CDATA[ After October’s Alt .Net demo of “Event-Driven SOA with NServiceBus” I decided to put together some additional thoughts about NServiceBus with respect to where and how it fits or can fit within the enterprise, for those who still may have questions like “now what?”  How, not only does NServiceBus’ use apply to Service-Oriented Architecture (SOA) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.scottmfelder.com&amp;blog=10210771&amp;post=22&amp;subd=scottfelder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div class="mceTemp mceIEcenter">
<div class="mceTemp mceIEcenter" style="text-align:left;"> After October’s Alt .Net demo of “Event-Driven SOA with NServiceBus” I decided to put together some additional thoughts about NServiceBus with respect to where and how it fits or can fit within the enterprise, for those who still may have questions like “now what?”  How, not only does NServiceBus’ use apply to Service-Oriented Architecture (SOA) and Event-Driven Architecture (EDA), but also with Domain Driven Design (DDD).</div>
</div>
<p><strong></strong> </p>
<p><strong>Big Ball of Mud</strong></p>
<p>Let’s start with my original example business, Acme Enterprise.  Acme wishes to build an ecommerce system to sell its products to its customers.  The developers at Acme start out by building a web application that customers can come to for placing orders, employees in the pricing department can update product prices, and employees in the inventory management department can maintain product SKUs and product levels.  As time goes on the pricing department wants to add new functionality to the system to maintain promotional pricing on products, discount pricing on products, etc.  The inventory department wants to add new functionality to the system to provide auto-replenishment on products, warehouse location of products, etc.  As the application grows into one monolithic system it can quickly become unmanageable in its current form, or as some call it, BBOM – Big Ball of Mud.  More importantly, the different departments within Acme define the term “Product” differently.  The sales department defines a “Product” as an item ordered by a customer and added to a shopping cart with a <em>price</em> and <em>quantity ordered</em> information attached to it.  The pricing department defines the “product” in terms of not only unit price, but promotional pricing, and marketing campaign pricing that is valid for a particular time period. Meanwhile the folks in inventory management define a “Product” in terms of <em>Quantity on Hand</em>, <em>Warehouse Location</em>, and <em>Reorder Threshold Trigger</em>.  As the system grows, so does the complexity and the size of our BBOM.</p>
<div class="mceTemp mceIEcenter"><img class="aligncenter size-full wp-image-8" title="NSB-BBM" src="http://scottfelder.files.wordpress.com/2009/11/nsb-bbm.png" alt="NSB-BBM" width="385" height="282" /></div>
<p><strong> </strong></p>
<p><strong>Bounded Contexts</strong></p>
<p>This is where Domain Driven Design (DDD) can help with the design of our ecommerce system.  When we start to define the term “Product” with the people responsible for products in each of the departments within the company, we realize that they all care about this thing called a “Product” but they each talk about it in a different context.  This is where DDD introduces the idea of a Bounded Context.  Our system can be split into separate contexts each with its own explicit boundary.  So what we end up with in our system is a bunch of Bounded Contexts for each of the different contexts within the system: an inventory context, a pricing context, sales context, etc.  Each Bounded Context has its own model and ubiquitous language that defines the domain and entities like “Product” uniquely to its own definition.  The key phrase to our bounded context here is “explicit boundary”.  Each context provides a contract to the outside world to interact with and can be viewed as its own application within an application.  This can provide modularity to our overall system design.  One Bounded Context shares data with another Bounded Context via a Context Map.  A Context Map exposes a well defined contract interface that can be consumed.</p>
<p style="text-align:center;"><img class="size-full wp-image-11  aligncenter" title="NSB-DDD" src="http://scottfelder.files.wordpress.com/2009/11/nsb-ddd.png" alt="NSB-DDD" width="418" height="406" /></p>
<p><strong> </strong> </p>
<p><strong> </strong></p>
<p><strong>Bounded Context as a Service</strong></p>
<p>Now let’s take our DDD ecommerce system and apply SOA principles to it. Remember when I stated that a Bounded Context provides an explicit boundary?  One of the core tenets of SOA states that “Boundaries are explicit”.  I also stated that a Bounded Context can provide modularity within our system and that a context can be viewed as an application within an application.  Well another core tenet of SOA states that “Services are autonomous.” Hmm, so what else do bounded contexts and SOAs share in common?  A Bounded Context within our system communicates with another Bounded Context within our system via a context map that provides a contract interface to the outside world.  SOA; “Services share Schema and Contract, not Class”.  So when we compare the Bounded Context of our DDD and the Services of our SOA, there really isn’t a whole lot of difference between the two.  Maybe in an SOA we should call them “Bounded Services”?  SOA is about the separation of Bounded Contexts in our application into their own services so looser coupling can be achieved while providing a certain degree of service reuse within our enterprise.  Our context map or interface to the SOA service can be done via a web service, restful service, or WCF.  For example, in our DDD ecommerce application, if we wanted to replace the inventory context with a third party inventory management or ERP system like SAP, there may be a bit more work involved to decouple it from the old system and integrate the new SAP system.  With SOA, we have a lesser degree of coupling to deal with so integrating to the new inventory system will be easier.  Notice, I said “easier” not seamless.</p>
<p style="text-align:center;"> <img class="size-full wp-image-10  aligncenter" title="NSB-SOA" src="http://scottfelder.files.wordpress.com/2009/11/nsb-soa.png" alt="NSB-SOA" width="403" height="314" /></p>
<p><strong> </strong></p>
<p><strong>EDA with NServiceBus</strong></p>
<p>This brings me to Event-Driven Architecture (EDA), more specifically, EDA with NServiceBus.  As we’ve taken our initial BBOM ecommerce application and we introduced DDD principles to it and refactored our system, we began to decouple the system into different functional modules, or Bounded Context, within one application running on our web server.  Each department (inventory, pricing, sales), would access the same system to update their various domains of information.  As we moved to SOA, we took this one step farther by making these contexts autonomous services that can be distributed on different servers running within our enterprise, providing user access to a particular service to only the people in the department that need to update data within that service.  The problem with traditional SOA is it still gives us a certain level of coupling with our enterprise applications between services.  If the inventory service needs to inform the pricing service that a new SKU has been entered into the system, the inventory service must know that the pricing service exists within our enterprise.  Meaning, the inventory service must be programmed to make a service call to a service interface (web service, WCF, socket call, etc.) on the pricing service.  If we decide to use a different system in the future to do pricing, we need to update the inventory service to call the new service interfaces on the new pricing system.  This is where event messages and NServiceBus can help.  If we define a series of business events that describe important transactions within our enterprise, we can publish their event messages to a message bus.  Now instead of our services interacting directly and having to be aware of one another in the enterprise, each service only needs to know to publish event messages to the message bus, and only subscribe to event messages on the message bus that it cares about.  So in the case of our inventory service, and our pricing service, the inventory service can publish“New SKU” events and the pricing service and subscribe to “New SKU” events.  At no point does the inventory service need to know about the pricing service and conversely, the pricing service doesn’t need to know about the inventory service; now what “links” the two systems together are the “New SKU” events, and more importantly the data contained within.  In essence, the event messages and the service bus, in this case NServiceBus (but we could use others) become the “Context Map” defined back in our DDD application.  The event messages are our contracts and NServiceBus becomes our service transport layer to communicate between Bounded Contexts/Services with a higher level of decoupling between our services than we had with our traditional SOA.</p>
<p style="text-align:center;"><img class="aligncenter size-full wp-image-12" title="NSB-EDA" src="http://scottfelder.files.wordpress.com/2009/11/nsb-eda.png" alt="NSB-EDA" width="426" height="293" /> </p>
<p><strong> </strong></p>
<p><strong>In conclusion</strong></p>
<p>            NServiceBus provides an easy to use API to the framework to work with so we can create an event message driven architecture.  Publishing event messages via NServiceBus will allow for a much more loose coupling design between the different Bounded Contexts or Services running in our enterprise.  While applications or services will always have a higher degree of coupling between their application layers, (UI, Business Layer, DAL, etc.), Event-Driven Architecture with NServiceBus can provide for a much lesser degree of coupling between the explicit boundaries of the services.</p>
<br />Posted in Alt .Net, DDD, EDA, NServiceBus, SOA Tagged: Alt .Net, DDD, EDA, Event-Driven SOA, NServiceBus, SOA <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/scottfelder.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/scottfelder.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/scottfelder.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/scottfelder.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/scottfelder.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/scottfelder.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/scottfelder.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/scottfelder.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/scottfelder.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/scottfelder.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/scottfelder.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/scottfelder.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/scottfelder.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/scottfelder.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.scottmfelder.com&amp;blog=10210771&amp;post=22&amp;subd=scottfelder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.scottmfelder.com/2009/11/04/event-driven-soa-with-nservicebus/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3ba60f8a682cbf7ee173be26d18c88f7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">scottfelder</media:title>
		</media:content>

		<media:content url="http://scottfelder.files.wordpress.com/2009/11/nsb-bbm.png" medium="image">
			<media:title type="html">NSB-BBM</media:title>
		</media:content>

		<media:content url="http://scottfelder.files.wordpress.com/2009/11/nsb-ddd.png" medium="image">
			<media:title type="html">NSB-DDD</media:title>
		</media:content>

		<media:content url="http://scottfelder.files.wordpress.com/2009/11/nsb-soa.png" medium="image">
			<media:title type="html">NSB-SOA</media:title>
		</media:content>

		<media:content url="http://scottfelder.files.wordpress.com/2009/11/nsb-eda.png" medium="image">
			<media:title type="html">NSB-EDA</media:title>
		</media:content>
	</item>
	</channel>
</rss>
