<?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/"
	>

<channel>
	<title>Udi Dahan - The Software Simplist &#187; NServiceBus</title>
	<atom:link href="http://www.udidahan.com/category/nservicebus/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.udidahan.com</link>
	<description>Enterprise Development Expert &#38; SOA Specialist</description>
	<lastBuildDate>Tue, 31 Aug 2010 09:56:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Race Conditions Don&#8217;t Exist</title>
		<link>http://www.udidahan.com/2010/08/31/race-conditions-dont-exist/</link>
		<comments>http://www.udidahan.com/2010/08/31/race-conditions-dont-exist/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 09:56:46 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[BPM]]></category>
		<category><![CDATA[Business Rules]]></category>
		<category><![CDATA[CQRS]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Pub/Sub]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://www.udidahan.com/?p=1335</guid>
		<description><![CDATA[Not in the business world anyway.
The problem is that, as software developers, we&#8217;re all too quick to accept them at face value. We don&#8217;t question the requirements &#8211; in all fairness, it was never our job to do so. We were the ones that implemented them, preferably quickly. 
For example
Let&#8217;s say we get the requirement [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.udidahan.com/wp-content/uploads/crossing-the-finish-line1.jpg" alt="crossing-the-finish-line" title="crossing-the-finish-line" width="200" height="159" style="float:right; margin-left:10px; margin-bottom:10px;"  />Not in the business world anyway.</p>
<p>The problem is that, as software developers, we&#8217;re all too quick to accept them at face value. We don&#8217;t question the requirements &#8211; in all fairness, it was never our job to do so. We were the ones that implemented them, preferably quickly. </p>
<h3>For example</h3>
<p>Let&#8217;s say we get the requirement the following requirements:</p>
<p>1. If the order was already shipped, don&#8217;t let the user cancel the order.<br />
2. If the order was already cancelled, don&#8217;t let the user ship the order.</p>
<p>The race condition here is when we have two users who are looking at the same order, which is neither cancelled nor shipped yet, and each submits a command &#8211; one to ship the order, the other to cancel it.</p>
<p>In these cases, the code is simple &#8211; just an if statement before performing the relevant command.</p>
<h3>So what&#8217;s the problem</h3>
<p>A microsecond difference in timing shouldn&#8217;t make a difference to core business behaviors. Which means that we&#8217;ve actually got here is a bug in the requirements. Users are actually dictating solutions here rather than requirements.</p>
<p>Let&#8217;s ask our stakeholders, &#8220;why shouldn&#8217;t we let users cancel a shipped order? I mean, the users don&#8217;t want the products.&#8221;</p>
<p>And the stakeholders would respond with something like, &#8220;well, we don&#8217;t want to refund the user&#8217;s money then. Or, at least, not all their money. Well, maybe if they return the products in their original packaging, *then* we could give a full refund.&#8221;</p>
<p>And as we drilled deeper, &#8220;when do refunds need to be given? Right away, in the same transaction?&#8221;</p>
<p>The stakeholders would explain, &#8220;no, refunds don&#8217;t need to be given right away.&#8221;</p>
<p>It turns out we were missing the concept of a refund, as well as assuming that all things needed to be processed and enforced immediately. Once we dug into the requirements, we found that there is actually plenty of time to allow both transactions to go through. We just need to add some checks during shipping&#8217;s long-running process to see if the order was cancelled, and then to cut the process short.</p>
<h3>So is everything a long-running process then?</h3>
<p>That&#8217;s actually a fair question &#8211; long-running processes are a lot more common than at first appears.</p>
<p>What we&#8217;re seeing is that cancellation is now a command that has no reason to fail &#8211; just like <a href="http://www.udidahan.com/2009/12/09/clarified-cqrs">CQRS</a> tells us. When this command is performed, it publishes the OrderCancelled event, which the billing service subscribes to. </p>
<p>Billing then starts a long-running process (a saga, in <a href="http://www.NServiceBus.com">NServiceBus</a> lingo), also listening to events from the shipping process, ultimately making a decision when a refund should be given, and for how much.</p>
<h3>Deeper business analysis</h3>
<p>As we discuss matters more with our business stakeholders, we hear that most orders are actually cancelled within an hour of being submitted. It is quite rare for orders to be cancelled days later.</p>
<p>In which case, we could look at modeling the acceptance of an order as a long-running process itself.</p>
<p>When a user places an order, we don&#8217;t immediately publish an event indicating the acceptance of an order, instead a saga is kicked off &#8211; which opens up a timeout for an hour later. If a cancellation command arrives during that period of time, the user gets a full refund (seeing as we didn&#8217;t charge anything since billing didn&#8217;t get the accepted event to begin with), and the saga just shuts itself down. If the timeout occurs an hour later, and the saga didn&#8217;t get a cancel command, then the order is actually accepted and the event is published.</p>
<p>Yes, sagas are everywhere, once you learn to see with business eyes, and no race conditions are left.</p>
<h3>In closing</h3>
<p>Any time you see requirements that indicate a race condition, dig deeper.</p>
<p>What you&#8217;re likely to find are some additional business concepts as well as the introduction of time and the creation of long-running business processes. The implementation at that point will pivot from being trivial if-statements to being richer sagas.</p>
<p>Keep an eye out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2010/08/31/race-conditions-dont-exist/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>NServiceBus &#8211; .NET Service Bus Smackdown</title>
		<link>http://www.udidahan.com/2010/08/04/nservicebus-net-service-bus-smackdown/</link>
		<comments>http://www.udidahan.com/2010/08/04/nservicebus-net-service-bus-smackdown/#comments</comments>
		<pubDate>Wed, 04 Aug 2010 11:24:39 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[MSMQ]]></category>
		<category><![CDATA[Messaging]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">http://www.udidahan.com/?p=1322</guid>
		<description><![CDATA[I get this question quite often: &#8220;what is the difference between NServiceBus and the .NET Service Bus from Microsoft?&#8221; And I&#8217;m afraid the answer is that the two technologies were designed to handle a very different set of problems. 
The .NET Service Bus was designed to bridge internet communications using the cloud to enable a [...]]]></description>
			<content:encoded><![CDATA[<p>I get this question quite often: &#8220;what is the difference between NServiceBus and the .NET Service Bus from Microsoft?&#8221; And I&#8217;m afraid the answer is that the two technologies were designed to handle a very different set of problems. </p>
<p>The .NET Service Bus was designed to bridge internet communications using the cloud to enable a variety of devices to communicate using a WCF-remote-procedure-call type of API. NServicebus was designed to simplify the design of on-premise distributed systems using reliable messaging.</p>
<p>Still, people seem to want a kind of comparison, so here&#8217;s a quick one off-the-top-of-my-head:</p>
<table style="text-align:center; font-size:12px;" border="1">
<tr style="font-weight:bold; font-size:16px;">
<td>Feature</td>
<td>.NET Service Bus</td>
<td>NServiceBus</td>
</tr>
<tr>
<td>Cloud-based messaging</td>
<td>Yes</td>
<td>No</td>
</tr>
<tr>
<td>Internet-spanning communication</td>
<td>Yes</td>
<td>Yes &#8211; via additional gateway process</td>
</tr>
<tr>
<td>Lightweight client support</td>
<td>Yes</td>
<td>Yes &#8211; via exposed WCF endpoint</td>
</tr>
<tr>
<td>Full duplex communication</td>
<td>Yes</td>
<td>Yes &#8211; not including lightweight clients</td>
</tr>
<tr>
<td>Publish / Subscribe support</td>
<td>Yes</td>
<td>Yes</td>
</tr>
<tr>
<td>Interop with non-.Net platforms</td>
<td>Yes</td>
<td>Yes</td>
</tr>
<tr>
<td>Maximum message size</td>
<td>64 KB</td>
<td>4012 KB</td>
</tr>
<tr>
<td>Long-running stateful processes</td>
<td>Using WF on top</td>
<td>Yes</td>
</tr>
<tr>
<td>On-premise messaging</td>
<td>No</td>
<td>Yes</td>
</tr>
<tr>
<td>Client can send messages if server is offline</td>
<td>No</td>
<td>Yes</td>
</tr>
<tr>
<td>Poison message detection and dispatching</td>
<td>No</td>
<td>Yes</td>
</tr>
<tr>
<td>Poison messages re-processing</td>
<td>No</td>
<td>Yes</td>
</tr>
<tr>
<td>Subscriptions persist after restart</td>
<td>No</td>
<td>Yes</td>
</tr>
<tr>
<td>Polymorphic message dispatch</td>
<td>No</td>
<td>Yes</td>
</tr>
<tr>
<td>Polymorphic message routing</td>
<td>No</td>
<td>Yes</td>
</tr>
<tr>
<td>Message-driven unit testing</td>
<td>No</td>
<td>Yes</td>
</tr>
</table>
<p>This is not meant to be an exhaustive list, or even an accurate representation of the relative strengths and weaknesses of the technologies because, as I said, they&#8217;re designed for different purposes. </p>
<p>One could even plug the .NET Service Bus into NServiceBus instead of its MSMQ transport to get broad reach where required, and then switching back to the on-premise strengths of MSMQ. The pluggability of NServiceBus makes it easy to swap out almost all implementation components like the subscription storage, transport, authorization mechanisms, containers, etc.</p>
<p>For more information on the .NET Service Bus see the <a href="http://www.microsoft.com/windowsazure/appfabric/">Azure AppFabric page</a>. Juval Lowey also has a nice article on it up on MSDN magazine <a href="http://msdn.microsoft.com/en-us/magazine/dd569756.aspx">here</a>.</p>
<p>For more information on NServiceBus see the <a href="http://www.NServiceBus.com">NServiceBus site</a>. Also take a look at the pages giving you comparisons to WCF and BizTalk.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2010/08/04/nservicebus-net-service-bus-smackdown/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Cautiously Merging IL</title>
		<link>http://www.udidahan.com/2010/08/01/cautiously-merging-il/</link>
		<comments>http://www.udidahan.com/2010/08/01/cautiously-merging-il/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 07:16:53 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Simplicity]]></category>

		<guid isPermaLink="false">http://www.udidahan.com/?p=1318</guid>
		<description><![CDATA[As Dru mentioned on his blog, while having dinner in Kansas City, I described why NServiceBus makes use of IL Merge and some of the challenges we were facing with version management as a result. While I do think that we&#8217;ve managed to find the right balance, I must say that it wasn&#8217;t easy and [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.udidahan.com/wp-content/uploads/merge.gif" alt="Caution, Merge Ahead" title="Caution, Merge Ahead" width="200" height="200" style="float:right; margin-left:10px; margin-bottom:10px;" />As Dru <a href="http://codebetter.com/blogs/dru.sellers/archive/2010/07/29/ilmerge-to-the-rescue.aspx">mentioned on his blog</a>, while having dinner in Kansas City, I described why NServiceBus makes use of IL Merge and some of the challenges we were facing with version management as a result. While I do think that we&#8217;ve managed to find the right balance, I must say that it wasn&#8217;t easy and I urge other developers use caution when employing it.</p>
<h3>Mistakes Made</h3>
<p>In the previous version of NServiceBus (1.9) we over aggresively merged 3rd party libraries like Castle into the NServiceBus binaries. That in itself, wasn&#8217;t the big problem. The problem was that we didn&#8217;t know about <i>internalizing</i> the libraries we merged. </p>
<p>This resulted in all the 3rd party types being exposed when a developer used NServiceBus. For those who happened to use the same version of those libraries as that which was merged, it wasn&#8217;t a problem. Unfortunately, developers who used libraries like Castle tended to be very particular about which version they used &#8211; which resulted in version conflicts, also known as &#8220;versioning hell&#8221;.</p>
<h3>Internalization Challenges</h3>
<p>As we moved to NServiceBus 2.0, we were a lot more careful about which libraries were merged and made sure to internalize them as much as possible. Yes, you read that right, &#8220;as much as possible&#8221;. You can&#8217;t always internalize all the types of a given library.</p>
<p>For example, NServiceBus internally uses NHibernate to persist the state of long-running processes (called sagas) and we want this implementation detail to not conflict with anything that developers want to do on top of NServiceBus. The only thing is that for NHibernate to work, it needs certain types to be exposed to the configuration environment, specifically all the types in the NHibernate.Cfg.MappingSchema namespace.</p>
<h3>Extensibility Challenges</h3>
<p>Once you take on an external dependency, you want to configure it to &#8220;just work&#8221; so that developers that aren&#8217;t familiar with it don&#8217;t have to learn yet another library to use your framework. So far, we&#8217;ve been able to do that quite successfully with NServiceBus. The challenge comes when developers want to customize the behavior of those 3rd party libraries, wanting to call into their APIs.</p>
<p>You see, once you internalize those libraries and their types, developers can&#8217;t access them. This leads to all sorts of tricky extensibility problems especially for different kinds of developers. Some are happy enough to configure things from the outside using XML &#8211; like using hbm.xml files to describe how their sagas get persisted, while others really want to use Fluent NHibernate, which is fully internalized.</p>
<h3>Finding a Balance</h3>
<p>What we&#8217;ve currently got for NServiceBus to try to keep everyone happy is a progressive exposure model. From the developer who&#8217;s downloading NServiceBus for the first time and wants everything to just work without changing anything, our API unfolds in multiple dimensions to allow for the highest level of extensibility and pluggability. That being said, the Fluent NHibernate issue mentioned above isn&#8217;t solvable at just an API level.</p>
<p>In order to address the class of developer that wants full control, we&#8217;ve got a &#8220;core only&#8221; build that doesn&#8217;t merge any assemblies into it. This class of developer usually doesn&#8217;t have a problem with referencing some more assemblies as long as they retain full control of the behaviors they want.</p>
<p>It ain&#8217;t easy keeping everybody happy, or, at least, not unhappy.</p>
<h3>In Closing</h3>
<p>I would agree that more OSS frameworks should merge and internalize 3rd party libraries that don&#8217;t need to be exposed to developers &#8211; it shortens the learning curve and increases adoption. But walk this path cautiously, it&#8217;s hard striking a balance that will work all users of your framework and it takes quite some time to get it right.</p>
<p>And one last thing, please, PLEASE, take care of maintaining binary compatibility from one version to the next. I know it&#8217;s a pain &#8211; we&#8217;ve been doing it with NServiceBus for the past 3 years, but your users will thank you for it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2010/08/01/cautiously-merging-il/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Evolving Loosely-Coupled Frameworks &amp; Apps</title>
		<link>http://www.udidahan.com/2010/07/14/evolving-loosely-coupled-frameworks-and-apps/</link>
		<comments>http://www.udidahan.com/2010/07/14/evolving-loosely-coupled-frameworks-and-apps/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 13:10:18 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Dependency Injection]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[OO]]></category>
		<category><![CDATA[Simplicity]]></category>

		<guid isPermaLink="false">http://www.udidahan.com/?p=1312</guid>
		<description><![CDATA[This post will be less of a big-concept type posts I usually do, and more of a tip for people building and maintaining infrastructure and frameworks either open-source or internally for their companies. I&#8217;m going to illustrate this with NServiceBus as it is a large enough code base to have significant complexity and open so [...]]]></description>
			<content:encoded><![CDATA[<p>This post will be less of a big-concept type posts I usually do, and more of a tip for people building and maintaining infrastructure and frameworks either open-source or internally for their companies. I&#8217;m going to illustrate this with NServiceBus as it is a large enough code base to have significant complexity and open so that you can go and take a look yourself. Trying to include some example in here would be just too small to be useful or for the point to come across.</p>
<h3>Some background</h3>
<p>As a cohesive framework, NServiceBus makes it quite easy for developers to pick and choose which settings they want turned on and off. Being built as a loosely-coupled set of components that don&#8217;t know about each other has always kept the internal complexity low. But as the NServiceBus API has been evolving over the years, and the functionality offered has increased, some interesting challenges have popped up as the codebase has been refactored. </p>
<h3>The challenge</h3>
<p>The UnicastBus class has grown too large and it&#8217;s time to refactor something out. Coincidentally, users have been asking for a better &#8220;header&#8221; story for messages &#8211; the ability to specify static headers that will be appended to all messages being sent (useful for things like security tokens), as well as per message headers. So, we want to refactor all the header management out to its own component independent of the UnicastBus class.</p>
<p>So, here&#8217;s the issue. So far, users have specified &#8220;.UnicastBus()&#8221; as a part of the fluent code-configuration, and shouldn&#8217;t have to change that &#8211; they shouldn&#8217;t need to know that header management is now a separate component. But then how can the new component bootstrap itself into the startup, such that it gets all the dependency injection facilities of the rest of the framework? Remember that the component doesn&#8217;t know which container technology is being used (since the user can swap it out) or when the container has been set.</p>
<h3>The solution</h3>
<p>The only part of the framework that knows about when all DI configuration is set is the configuration component, thus it will have to be the one that invokes the new component (without knowing about it). Introduce an interface (say INeedInitialization) and scan all the types loaded looking for classes which implement that type, register them into the container, and invoke them. Have the new component implement that interface, and in its initialization have it hook into the events and/or pipelines of other parts of the system.</p>
<h3>Other uses</h3>
<p>One historically problematic area in NServiceBus has been people forgetting to call &#8220;.LoadMessageHandlers()&#8221;. This can now be wired in automatically by a class in the UnicastBus component via the same mechanism.</p>
<p>A new feature coming in the next version is the &#8220;data bus&#8221;, a component which will allow sending large quantities of data through the bus without going through the messaging pipelines. This will help people get around the 4MB limit of MSMQ and, even more importantly, the much smaller 8KB limit of Azure. We will be able to introduce the functionality transparently with the same mechanism.</p>
<p>As an extension point, developers can now enrich the NServiceBus framework with their own capabilities and make those available via the contrib project to the community at large. This is better than the IWantToRunAtStartup interface that was only available for those using the generic host (which excluded web apps) and gives a consistent extensibility story for all uses.</p>
<h3>Summary</h3>
<p>Extensibility has always been a challenge when writing object-oriented code and dependency injection techniques have helped, but sometimes you need a bit more to take things to the next level while maintaining a backwards-compatible API.</p>
<p>Like I said, not a ground-shaking topic but something quite necessary in creating loosely-coupled frameworks and applications. Once you know it&#8217;s there, it isn&#8217;t really a big deal. If you didn&#8217;t know to do it, you may have been contorting your codebase in all kinds of ways to try to achieve similar things.</p>
<p>If you want to take a look at the code, you can find the SVN repository here: https://nservicebus.svn.sourceforge.net/svnroot/nservicebus/trunk/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2010/07/14/evolving-loosely-coupled-frameworks-and-apps/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CQRS, DDD, and NServiceBus video</title>
		<link>http://www.udidahan.com/2010/06/18/cqrs-ddd-and-nservicebus-video/</link>
		<comments>http://www.udidahan.com/2010/06/18/cqrs-ddd-and-nservicebus-video/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 11:11:19 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[CQRS]]></category>
		<category><![CDATA[DDD]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Presentations]]></category>

		<guid isPermaLink="false">http://www.udidahan.com/?p=1306</guid>
		<description><![CDATA[Following the theme of my last few blog posts, this post will also be pointing you to videos of me talking.
After I had finished speaking at QCon London last March, I sat down for a short interview with the guys from InfoQ chatting about topics from CQRS, to DDD, to NServiceBus. I&#8217;m happy to say [...]]]></description>
			<content:encoded><![CDATA[<p>Following the theme of my last few blog posts, this post will also be pointing you to videos of me talking.</p>
<p>After I had finished speaking at QCon London last March, I sat down for a short interview with the guys from InfoQ chatting about topics from CQRS, to DDD, to NServiceBus. I&#8217;m happy to say that the interview is now online with a full (and mostly accurate) transcript as well as with an MP3 download link.</p>
<p>Get it here: <a href="http://www.infoq.com/interviews/dahan-cqrs-ddd-nservicebus">Udi Dahan on CQRS, DDD and NServiceBus</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2010/06/18/cqrs-ddd-and-nservicebus-video/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NServiceBus Presentation Now Online</title>
		<link>http://www.udidahan.com/2010/06/09/nservicebus-presentation-now-online/</link>
		<comments>http://www.udidahan.com/2010/06/09/nservicebus-presentation-now-online/#comments</comments>
		<pubDate>Wed, 09 Jun 2010 21:43:51 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[ESB]]></category>
		<category><![CDATA[Messaging]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[Pub/Sub]]></category>
		<category><![CDATA[SOA]]></category>

		<guid isPermaLink="false">http://www.udidahan.com/?p=1298</guid>
		<description><![CDATA[Last April I was in Bergen Norway for some consulting and training and I also gave my first NServiceBus presentation to a user group. I don&#8217;t particularly like giving NServiceBus-specific presentations, preferring to talk about the patterns and concepts of service-based architectures and service buses &#8211; NServiceBus is just an implementation. Ultimately, that&#8217;s what happened [...]]]></description>
			<content:encoded><![CDATA[<p>Last April I was in Bergen Norway for some consulting and training and I also gave my first NServiceBus presentation to a user group. I don&#8217;t particularly like giving NServiceBus-specific presentations, preferring to talk about the patterns and concepts of service-based architectures and service buses &#8211; NServiceBus is just an implementation. Ultimately, that&#8217;s what happened in the presentation &#8211; in the first half (or so) I talked about the theory, and in the second I demonstrated that theory with NServiceBus.</p>
<p>Currently, the video is being graciously hosted by Jon Torresdal on his blog, so let&#8217;s hope that the bandwidth holds up.</p>
<p>Get it <a href="http://blog.torresdal.net/2010/06/08/NNUGPresentationUdiDahanOnNServiceBus.aspx">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2010/06/09/nservicebus-presentation-now-online/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ESB Differences Between Java and .NET</title>
		<link>http://www.udidahan.com/2010/03/29/esb-differences-between-java-and-net/</link>
		<comments>http://www.udidahan.com/2010/03/29/esb-differences-between-java-and-net/#comments</comments>
		<pubDate>Mon, 29 Mar 2010 13:53:52 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[BPM]]></category>
		<category><![CDATA[ESB]]></category>
		<category><![CDATA[MSMQ]]></category>
		<category><![CDATA[Messaging]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Podcast]]></category>
		<category><![CDATA[Pub/Sub]]></category>

		<guid isPermaLink="false">http://www.udidahan.com/?p=1212</guid>
		<description><![CDATA[At QCon London a couple of weeks ago I had a chat with Ross Mason, the founder of Mule &#8211; the open source Java ESB. After a while, I realized that NServiceBus is a bit different from Mule ESB in terms of scope.
While Mule has many features in terms of connectivity and integration, NServiceBus provides [...]]]></description>
			<content:encoded><![CDATA[<p>At QCon London a couple of weeks ago I had a chat with Ross Mason, the founder of <a href="http://www.mulesoft.com/mule-esb-open-source-esb">Mule &#8211; the open source Java ESB</a>. After a while, I realized that NServiceBus is a bit different from Mule ESB in terms of scope.</p>
<p>While Mule has many features in terms of connectivity and integration, NServiceBus provides platform interop only. One could say that this is a product of the different backgrounds I and Ross come from.  </p>
<p>On the other hand, the saga capabilities in NServiceBus for handling long-running processes are considered to be BPM functionality on the Java side of the industry, and as such, Mule does not have them.</p>
<p>In terms of other enterprise features like management and monitoring, Mule is more mature, but NServiceBus holds its own in terms of high availability and actually surpasses Mule with the grid and scale-out capabilities of its distributor.</p>
<p>Anyway, I think it&#8217;s about time each of these parts was explicitly described so that companies already invested in Java ESB tools will know what they&#8217;re getting with NServiceBus.</p>
<p>Until then, I hope this podcast describing the full spectrum of NServiceBus, from top level SOA services to in-the-weeds transaction management, will provide more information about what it is and why you might want to use it:</p>
<p><a href="http://deepfriedbytes.com/deepfriedbytes/podcast/episode-49-getting-the-right-message-about-nservicebus-with-udi-dahan/">Deep Fried Bytes, episode 49 &#8211; Getting the right message about NServiceBus with Udi Dahan</a>.</p>
<p>Comments most welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2010/03/29/esb-differences-between-java-and-net/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>NServiceBus 2.0 RTM</title>
		<link>http://www.udidahan.com/2010/03/01/nservicebus-2-0-rtm/</link>
		<comments>http://www.udidahan.com/2010/03/01/nservicebus-2-0-rtm/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 00:06:36 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[NServiceBus]]></category>

		<guid isPermaLink="false">http://www.udidahan.com/?p=1187</guid>
		<description><![CDATA[Well, it&#8217;s been a long time coming.
NServiceBus 2.0 RTM is now generally available.
There were some small tweaks after the RC2 but I&#8217;m happy to say that, all in all, this was a very quiet stabilization period. Key customers have reported very high levels of satisfaction with the NServiceBus stability, scalability, and simplicity.
For example
Conduit.com has very [...]]]></description>
			<content:encoded><![CDATA[<p>Well, it&#8217;s been a long time coming.</p>
<p>NServiceBus 2.0 RTM is now generally available.</p>
<p>There were some small tweaks after the RC2 but I&#8217;m happy to say that, all in all, this was a very quiet stabilization period. Key customers have reported very high levels of satisfaction with the NServiceBus stability, scalability, and simplicity.</p>
<h3>For example</h3>
<p><a href="http://www.Conduit.com">Conduit.com</a> has very happily doubled their user base with NServiceBus to 100 million.</p>
<p>#1 on American Banker&#8217;s 100 top financial tech companies, <a href="http://www.fiserv.com/">Fiserv</a> has been quietly employing NServiceBus across many of their core services.</p>
<p>The Irish SaaS company <a href="http://www.candidatemanager.net/">Candidate Manager</a> have been running the automated HR processes of geographically distributed giants like Hilton International on NServiceBus without missing a beat.</p>
<h3>Community</h3>
<p>Now with an <a href="http://tech.groups.yahoo.com/group/nservicebus/">active community</a> of over 600 members, new users are quickly brought up to speed by the veterans and the much improved <a href="http://www.nservicebus.com/Documentation.aspx">documentation</a> on the site make adopting NServiceBus simpler than ever.</p>
<p>Training on NServiceBus has also ramped up nicely with the April course in Philadelphia now sold out. The next course will be in London in May <a href="http://skillsmatter.com/course/open-source-dot-net/advanced-distributed-systems-design-with-soa/ps-314">via Skills Matter</a>.</p>
<p>More courses are being planned in:</p>
<ul>
<li><a href="http://udidahan-toronto.eventbee.com/">Toronto, Canada</a> Aug 9-13</li>
<li><a href="http://udidahan-calgary.eventbee.com/">Calgary, Canada</a> in September</li>
<li><a href="mailto:Johannesburg@UdiDahan.com">Johannesburg, South Africa</a> in October</li>
<li><a href="mailto:Sydney@UdiDahan.com">Sydney, Australia</a> in November</li>
<li><a href="mailto:Seattle@UdiDahan.com">Seattle WA, USA</a> in December</li>
</ul>
<h3>Give it a try</h3>
<p>You&#8217;ll have publish/subscribe messaging working in under 5 minutes with a simple F5 on the PubSub sample.</p>
<p><a href="http://www.NServiceBus.com">Get it here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2010/03/01/nservicebus-2-0-rtm/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>NServiceBus 2.0 Release Candidate 2 Available</title>
		<link>http://www.udidahan.com/2010/02/01/nservicebus-2-0-release-candidate-2-available/</link>
		<comments>http://www.udidahan.com/2010/02/01/nservicebus-2-0-release-candidate-2-available/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 13:13:21 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[ESB]]></category>
		<category><![CDATA[MSMQ]]></category>
		<category><![CDATA[Messaging]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Pub/Sub]]></category>

		<guid isPermaLink="false">http://www.udidahan.com/?p=1173</guid>
		<description><![CDATA[So it&#8217;s been about 6 months since my last NServiceBus post and since then about 1000 new people have subscribed to this blog so they might not know anything about it. For a bit of history, see the post (from almost exactly a year ago) describing the 1.9 release of NServiceBus here.
What&#8217;s New
The quickly approaching [...]]]></description>
			<content:encoded><![CDATA[<p>So it&#8217;s been about 6 months since my last NServiceBus post and since then about 1000 new people have subscribed to this blog so they might not know anything about it. For a bit of history, see the post (from almost exactly a year ago) describing the 1.9 release of NServiceBus <a href="http://www.udidahan.com/2009/02/07/nservicebus-19/">here</a>.</p>
<h2>What&#8217;s New</h2>
<p>The quickly approaching next release of NServiceBus will be version 2.0 and is a big step from 1.9. After 2 betas and 2 release candidates, this version has had a longer stabilization period than any of the versions so far (1.4-1.9). Many of my clients are already using it in production and are very pleased with it. I&#8217;ve heard similar reports from others in the community (now with over 500 members in the discussion group). There have been almost 10,000 downloads since the version 1.9 release and in every country I visit I meet people using NServiceBus in new and interesting applications.</p>
<p>With my appearance on <a href="http://www.hanselminutes.com/default.aspx?showID=194">Hanselminutes</a>, many in the mainstream .NET industry have started taking a look at NServiceBus. That, and the fact that Microsoft&#8217;s Oslo technology has now taken a very data-driven turn (rather than its original service-oriented direction).</p>
<p>Interestingly enough, I&#8217;ve been hearing more and more reports about people using NServiceBus as a developer-friendly API on top of other technologies. This includes BizTalk and even Neuron. I never thought that people would take the pluggability of NServiceBus that far.</p>
<h2>So, what is NServiceBus?</h2>
<p>Well, it&#8217;s a service bus, y&#8217;know, like an ESB &#8211; just an open-source one.</p>
<p>All kidding aside, in a nutshell, it gives you an easy way to integrate transactional messaging into your applications.</p>
<p>One of the reasons why you might want to do that is so that you don&#8217;t lose messages containing valuable data when IIS recycles your AppDomain, every 15-20 minutes (as I wrote about in <a href="http://msdn.microsoft.com/en-us/magazine/cc663023.aspx">this MSDN magazine article</a>).</p>
<p>There are many other nice things in there, like the ability to unit test your service layers and long-running processes but you can read more about that here&#8230;</p>
<h2>Documentation</h2>
<p>One of the biggest differences to NServiceBus in this release is <b>documentation</b>.</p>
<p>A lot of work has gone into the <a href="http://www.NServiceBus.com">NServiceBus.com</a> site to help developers hit the ground running with NServiceBus, including the more advanced aspects of <a href="http://www.nservicebus.com/Distributor.aspx">transparent scale-out with the distributor</a> and <a href="http://www.nservicebus.com/Gateway.aspx">multi-site communications</a>.</p>
<p>There is still work to be done in this area but feedback so far has been extremely positive (except for some grumblings from certain old-timers saying that if they could figure it out by themselves, well, you know the rest).</p>
<h2>In Closing</h2>
<p>If you&#8217;re building a distributed enterprise .NET system, take 5 minutes, download it, and see transactional publish/subscribe messaging working on your machine without any big heavy-weight middleware.</p>
<p><a href="http://www.NServiceBus.com">www.NServiceBus.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2010/02/01/nservicebus-2-0-release-candidate-2-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hanselminutes on NServiceBus</title>
		<link>http://www.udidahan.com/2009/08/21/hanselminutes-on-nservicebus/</link>
		<comments>http://www.udidahan.com/2009/08/21/hanselminutes-on-nservicebus/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 19:53:11 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[ESB]]></category>
		<category><![CDATA[MSMQ]]></category>
		<category><![CDATA[Messaging]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Pub/Sub]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[WCF]]></category>

		<guid isPermaLink="false">http://www.udidahan.com/?p=1087</guid>
		<description><![CDATA[
Yesterday me and Scott virtually sat down to have a chat about NServiceBus and service buses in general. While we didn&#8217;t get in to many of the more advanced parts, you may find it an interesting introduction to the topic as well as saving yourself the costly mistake of implementing a broker instead of a [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.hanselman.com/blog/images/author.jpg" style="float:right; margin-left:10px; margin-bottom:10px;" /><br />
Yesterday me and Scott virtually sat down to have a chat about NServiceBus and service buses in general. While we didn&#8217;t get in to many of the more advanced parts, you may find it an interesting introduction to the topic as well as saving yourself the costly mistake of implementing a broker instead of a bus (yes &#8211; they&#8217;re actually two different things).</p>
<p><a href="http://www.hanselminutes.com/default.aspx?showID=194">Take a listen.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2009/08/21/hanselminutes-on-nservicebus/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Convention over Configuration &#8211; The Next Generation?</title>
		<link>http://www.udidahan.com/2009/08/15/convention-over-configuration-the-next-generation/</link>
		<comments>http://www.udidahan.com/2009/08/15/convention-over-configuration-the-next-generation/#comments</comments>
		<pubDate>Sat, 15 Aug 2009 18:13:24 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.udidahan.com/?p=1081</guid>
		<description><![CDATA[
Convention over configuration describes a style of development made popular by Ruby on Rails which has gained a great deal of traction in the .net ecosystem. After using frameworks designed in this way, I can say that the popularity is justified &#8211; it is much more pleasurable developing this way. 
The thing is, when looking [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.udidahan.com/wp-content/uploads/PicardKirk.jpg" alt="PicardKirk" title="PicardKirk" width="160" height="103" style="float:right; margin-left:10px; margin-bottom:10px; " /><br />
Convention over configuration describes a style of development made popular by Ruby on Rails which has gained a great deal of traction in the .net ecosystem. After using frameworks designed in this way, I can say that the popularity is justified &#8211; it is much more pleasurable developing this way. </p>
<p>The thing is, when looking at this in light of the full software development lifecycle, there are signs that the waters run deeper than we might have originally thought.</p>
<p>Let&#8217;s take things one step at a time though&#8230;</p>
<h3>What is it?</h3>
<p><a href="http://en.wikipedia.org/wiki/Convention_over_configuration">Wikipedia tells us</a>:</p>
<blockquote><p>&#8220;Convention over Configuration (aka Coding by convention) is a software design paradigm which seeks to decrease the number of decisions that developers need to make, gaining simplicity, but not necessarily losing flexibility. The phrase essentially means a developer only needs to specify unconventional aspects of the application.&#8221;</p></blockquote>
<p>What this means is that frameworks built in this way have default implementations that can be swapped out if needed. So far so good.</p>
<h3>For example&#8230;</h3>
<p>In <a href="http://www.NServiceBus.com">NServiceBus</a>, there is an abstraction for how subscription data is stored and multiple implementations &#8211; one in-memory, another using a durable MSMQ queue, and a third which uses a database. The convention for that part of the system is that the MSMQ implementation will be used, unless something else is specified. </p>
<p>Developers wishing to specify a different implementation can specify the desired implementation in the container &#8211; either one that comes out of the box, or their own implementation of ISubscriptionStorage.</p>
<p>Things get more interesting when we consider the full lifecycle.</p>
<h3>Lifecycle effects</h3>
<p>When developers are in the early phases of writing a new service, they want to focus primarily on what the service does &#8211; its logic. They don&#8217;t want to muck around with MSMQ queues for storing subscriptions and would much rather use the in-memory storage. </p>
<p>As the service takes shape and the developers want to run the full service on their machine, possibly testing basic fault-tolerance behaviors &#8211; kill one service, see that the others get a timeout, bring the service back up, wanting it to maintain all the previous subscriptions.</p>
<p>Moving on from there, our developers want to take the same system they just tested on their machine and move it into a staging environment. There, they don&#8217;t want to use the MSMQ implementation for subscription storage, but rather the database implementation &#8211; as will be used in the production environment. </p>
<p>While it may not sound like a big deal &#8211; changing the code which specifies which implementation to use when moving from one environment to another, consider that on top of just subscription storage, there is logging (output to console, file, db?), saga persistence (in-memory, file-based DB, relational DB), and more.</p>
<p>It&#8217;s actually quite likely that something will get missed as we move the system between environments. Can there be a better way?</p>
<h3>What if&#8230;</h3>
<p>What if there was some way for the developer to express their intent to the system, and the system could change its conventions, without the developer having to change any code or configuration files?</p>
<p>You might compare this (in concept) to debug builds and release builds. Same code, same config, but the runtime behaves different between the two.</p>
<p>As I mulled over how we could capture that intent without any code or config changes, the solution that I kept coming to seemed too trivial at first, so I dismissed it. Yet, it was the simplest one that would work for console and WinForms applications, as well as windows services &#8211; command line arguments. The only thing is that I don&#8217;t think those are available for web applications.</p>
<p>But since we&#8217;re still in &#8220;what if&#8221; land, and I&#8217;m more thinking out loud here than providing workable solutions for tomorrow morning, let&#8217;s &#8220;what if&#8221; command line arguments worked for web apps too.</p>
<h3>Command-Line Intent</h3>
<p>Going back to our original scenario, when developers are working on the logic of the service, they run it using the generic NServiceBus host process, passing it the command line parameter /lite (or whatever). The host then automatically configures all the in-memory implementations. </p>
<p>As the system progresses, when the developer wants to run everything on their machine, they run the processes with /integration. The host then configures the appropriate implementations (MSMQ for subscription storage, SQLite for saga persistence, etc. </p>
<p>When the developers want to run the system in production, they could specify /production (or maybe that could be the default?), and the database backed implementations would be configured.</p>
<h3>Imagine&#8230;</h3>
<p>Imagine being able to move that fluidly from one environment to another. Not needing to pore over configuration files or startup script code which configures a zillion implementation details. Not needing to worry that as you moved the system to staging something would break.</p>
<p>Imagine short, frictionless iterations even for large scale systems.</p>
<p>Imagine &#8211; lifecycle-aware frameworks making all this imagination a reality.</p>
<h3>In Closing</h3>
<p>We&#8217;re not there yet &#8211; but we&#8217;re not that far either. The generic host we&#8217;re providing with NServiceBus 2.0 is now being extended to support exactly these scenarios. </p>
<p>It&#8217;s my hope that as more of us think about this challenge, we&#8217;ll come up with better solutions and more intelligent frameworks. Just as convention came to our rescue before, breaking us out of the pain of endless XML configuration, I hope this new family of lifecycle-aware frameworks will make the friction of moving a system through dev, test, staging, and production a thing of the past.</p>
<p>A worthy problem for us all to solve, don&#8217;t you think?</p>
<p>Any ideas on how to make it a reality?<br />
Send them in &#8211; leave a comment below.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2009/08/15/convention-over-configuration-the-next-generation/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>A Queue Isn&#8217;t An Implementation Detail</title>
		<link>http://www.udidahan.com/2009/05/25/a-queue-isnt-an-implementation-detail/</link>
		<comments>http://www.udidahan.com/2009/05/25/a-queue-isnt-an-implementation-detail/#comments</comments>
		<pubDate>Mon, 25 May 2009 18:15:01 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[MSMQ]]></category>
		<category><![CDATA[Messaging]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">http://www.udidahan.com/?p=1015</guid>
		<description><![CDATA[It&#8217;s hard to believe that this continues to pop up even as WCF is reaching its fourth version (emphasis mine):
&#8220;A common complaint is that the first call on a client object takes some disproportionately large amount of time, usually ten seconds or more, while successive calls are instantaneous. There are many reasons why this might [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s hard to believe that this continues to pop up even as WCF is reaching its fourth version (emphasis mine):</p>
<blockquote><p>&#8220;A common complaint is that the first call on a client object takes some disproportionately large amount of time, <b>usually ten seconds or more</b>, while successive calls are instantaneous. There are many reasons why this might happen so <b>there&#8217;s no generic resolution for this problem</b>.&#8221; &#8212; <a href="http://blogs.msdn.com/drnick/archive/2009/05/22/tripping-over-missing-servers.aspx">Nicholas Allen</a></p></blockquote>
<p>The thing is that there <b>IS</b> a generic solution to this problem.</p>
<p>It&#8217;s queued messaging.</p>
<p>The only thing is that you have to give up talking to your services as if they were regular objects &#8211; calling methods on them and expecting a response. In other words, designing a distributed systems isn&#8217;t like designing a regular OO system just with some WCF sprinkled on top.</p>
<p>Even when trying to do fire and forget messaging on top of WCF (void method calls with the OneWay attribute), the underlying channel can still block your thread, as Nick mentioned. </p>
<p>A queue isn&#8217;t an implementation detail.<br />
It&#8217;s the primary architectural abstraction of a distributed system.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2009/05/25/a-queue-isnt-an-implementation-detail/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Saga Persistence and Event-Driven Architectures</title>
		<link>http://www.udidahan.com/2009/04/20/saga-persistence-and-event-driven-architectures/</link>
		<comments>http://www.udidahan.com/2009/04/20/saga-persistence-and-event-driven-architectures/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 11:50:44 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Autonomous Services]]></category>
		<category><![CDATA[EDA]]></category>
		<category><![CDATA[Messaging]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Pub/Sub]]></category>
		<category><![CDATA[SOA]]></category>

		<guid isPermaLink="false">http://www.udidahan.com/?p=992</guid>
		<description><![CDATA[When working with clients, I run into more than a couple of people that have difficulty with event-driven architecture (EDA). Even more people have difficulty understanding what sagas really are, let alone why they need to use them. I&#8217;d go so far to say that many people don&#8217;t realize the importance of how sagas are [...]]]></description>
			<content:encoded><![CDATA[<p><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; margin: 0px 0px 10px 10px; border-right-width: 0px" height="128" alt="image" src="http://www.udidahan.com/wp-content/uploads/saga_persistence.jpg" width="200" align="right" border="0" />When working with clients, I run into more than a couple of people that have difficulty with event-driven architecture (EDA). Even more people have difficulty understanding what sagas really are, let alone why they need to use them. I&#8217;d go so far to say that many people don&#8217;t realize the importance of how sagas are persisted in making it all work (including the Workflow Foundation team).</p>
<h3>The common e-commerce example</h3>
<p>We accept orders, bill the customer, and then ship them the product.</p>
<p>Fairly straight-forward.</p>
<p>Since each part of that process can be quite complex, let&#8217;s have each step be handled by a service:</p>
<p>Sales, Billing, and Shipping. Each of these services will publish an event when it&#8217;s done its part. Sales will publish OrderAccepted containing all the order information &#8211; order Id, customer Id, products, quantities, etc. Billing will publish CustomerBilledForOrder containing the customer Id, order Id, etc. And Shipping will publish OrderShippedToCustomer with its data.</p>
<p>So far, so good. EDA and SOA seem to be providing us some value.</p>
<h3>Where&#8217;s the saga?</h3>
<p>Well, let&#8217;s consider the behavior of the Shipping service. It shouldn&#8217;t ship the order to the customer until it has received the CustomerBilledForOrder event as well as the OrderAccepted event. In other words, Shipping needs to hold on to the state that came in the first event until the second event comes in. And this is exactly what sagas are for.</p>
<p>Let&#8217;s take a look at the saga code that implements this. In order to simplify the sample a bit, I&#8217;ll be omitting the product quantities.</p>
<p><!-- code formatted by http://manoli.net/csharpformat/ --></p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span>    <span class="kwrd">public</span> <span class="kwrd">class</span> ShippingSaga : Saga&lt;ShippingSagaData&gt;,</pre>
<pre><span class="lnum">   2:  </span>        ISagaStartedBy&lt;OrderAccepted&gt;,</pre>
<pre class="alt"><span class="lnum">   3:  </span>        ISagaStartedBy&lt;CustomerBilledForOrder&gt;</pre>
<pre><span class="lnum">   4:  </span>    {</pre>
<pre class="alt"><span class="lnum">   5:  </span>        <span class="kwrd">public</span> <span class="kwrd">void</span> Handle(OrderAccepted message)</pre>
<pre><span class="lnum">   6:  </span>        {</pre>
<pre class="alt"><span class="lnum">   7:  </span>            <span class="kwrd">this</span>.Data.ProductIdsInOrder = message.ProductIdsInOrder;</pre>
<pre><span class="lnum">   8:  </span>        }</pre>
<pre class="alt"><span class="lnum">   9:  </span>&nbsp;</pre>
<pre><span class="lnum">  10:  </span>        <span class="kwrd">public</span> <span class="kwrd">void</span> Handle(CustomerBilledForOrder message)</pre>
<pre class="alt"><span class="lnum">  11:  </span>        {</pre>
<pre><span class="lnum">  12:  </span>             <span class="kwrd">this</span>.Bus.Send&lt;ShipOrderToCustomer&gt;(</pre>
<pre class="alt"><span class="lnum">  13:  </span>                (m =&gt;</pre>
<pre><span class="lnum">  14:  </span>                {</pre>
<pre class="alt"><span class="lnum">  15:  </span>                    m.CustomerId = message.CustomerId;</pre>
<pre><span class="lnum">  16:  </span>                    m.OrderId = message.OrderId;</pre>
<pre class="alt"><span class="lnum">  17:  </span>                    m.ProductIdsInOrder = <span class="kwrd">this</span>.Data.ProductIdsInOrder;</pre>
<pre><span class="lnum">  18:  </span>                }</pre>
<pre class="alt"><span class="lnum">  19:  </span>                ));</pre>
<pre><span class="lnum">  20:  </span>&nbsp;</pre>
<pre class="alt"><span class="lnum">  21:  </span>            <span class="kwrd">this</span>.MarkAsComplete();</pre>
<pre><span class="lnum">  22:  </span>        }</pre>
<pre class="alt"><span class="lnum">  23:  </span>&nbsp;</pre>
<pre><span class="lnum">  24:  </span>        <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> Timeout(<span class="kwrd">object</span> state)</pre>
<pre class="alt"><span class="lnum">  25:  </span>        {</pre>
<pre><span class="lnum">  26:  </span>            </pre>
<pre class="alt"><span class="lnum">  27:  </span>        }</pre>
<pre><span class="lnum">  28:  </span>    }</pre>
</div>
<p>First of all, this looks fairly simple and straightforward, which is good.<br/><br />
It&#8217;s also wrong, which is not so good.</p>
<p>One problem we have here is that events may arrive out of order &#8211; first CustomerBilledForOrder, and only then OrderAccepted. What would happen in the above saga in that case? Well, we wouldn&#8217;t end up shipping the products to the customer, and customers tend not to like that (for some reason).</p>
<p>There&#8217;s also another problem here. See if you can spot it as I go through the explanation of ISagaStartedBy&lt;T&gt;.</p>
<h3>Saga start up and correlation</h3>
<p>The &#8220;ISagaStartedBy&lt;T&gt;&#8221; that is implemented for both messages indicates to the infrastructure (NServiceBus) that when a message of that type arrives, if an existing saga instance cannot be found, that a new instance should be started up. Makes sense, doesn&#8217;t it? For a given order, when the OrderAccepted event arrives first, Shipping doesn&#8217;t currently have any sagas handling it, so it starts up a new one. After that, when the CustomerBilledForOrder event arrives for that same order, the event should be handled by the saga instance that handled the first event &#8211; not by a new one.</p>
<p>I&#8217;ll repeat the important part: &#8220;the event should be handled by the saga instance that handled the first event&#8221;.</p>
<p>Since the only information we stored in the saga was the list of products, how would we be able to look up that saga instance when the next event came in containing an order Id, but no saga Id?</p>
<p>OK, so we need to store the order Id from the first event so that when the second event comes along we&#8217;ll be able to find the saga based on that order Id. Not too complicated, but something to keep in mind.</p>
<p>Let&#8217;s look at the updated code:</p>
<p><!-- code formatted by http://manoli.net/csharpformat/ --></p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span>    <span class="kwrd">public</span> <span class="kwrd">class</span> ShippingSaga : Saga&lt;ShippingSagaData&gt;,</pre>
<pre><span class="lnum">   2:  </span>        ISagaStartedBy&lt;OrderAccepted&gt;,</pre>
<pre class="alt"><span class="lnum">   3:  </span>        ISagaStartedBy&lt;CustomerBilledForOrder&gt;</pre>
<pre><span class="lnum">   4:  </span>    {</pre>
<pre class="alt"><span class="lnum">   5:  </span>        <span class="kwrd">public</span> <span class="kwrd">void</span> Handle(CustomerBilledForOrder message)</pre>
<pre><span class="lnum">   6:  </span>        {</pre>
<pre class="alt"><span class="lnum">   7:  </span>            <span class="kwrd">this</span>.Data.CustomerHasBeenBilled = <span class="kwrd">true</span>;</pre>
<pre><span class="lnum">   8:  </span>&nbsp;</pre>
<pre class="alt"><span class="lnum">   9:  </span>            <span class="kwrd">this</span>.Data.CustomerId = message.CustomerId;</pre>
<pre><span class="lnum">  10:  </span>            <span class="kwrd">this</span>.Data.OrderId = message.OrderId;</pre>
<pre class="alt"><span class="lnum">  11:  </span>&nbsp;</pre>
<pre><span class="lnum">  12:  </span>            <span class="kwrd">this</span>.CompleteIfPossible();</pre>
<pre class="alt"><span class="lnum">  13:  </span>        }</pre>
<pre><span class="lnum">  14:  </span>&nbsp;</pre>
<pre class="alt"><span class="lnum">  15:  </span>        <span class="kwrd">public</span> <span class="kwrd">void</span> Handle(OrderAccepted message)</pre>
<pre><span class="lnum">  16:  </span>        {</pre>
<pre class="alt"><span class="lnum">  17:  </span>            <span class="kwrd">this</span>.Data.ProductIdsInOrder = message.ProductIdsInOrder;</pre>
<pre><span class="lnum">  18:  </span>&nbsp;</pre>
<pre class="alt"><span class="lnum">  19:  </span>            <span class="kwrd">this</span>.Data.CustomerId = message.CustomerId;</pre>
<pre><span class="lnum">  20:  </span>            <span class="kwrd">this</span>.Data.OrderId = message.OrderId;</pre>
<pre class="alt"><span class="lnum">  21:  </span>&nbsp;</pre>
<pre><span class="lnum">  22:  </span>            <span class="kwrd">this</span>.CompleteIfPossible();</pre>
<pre class="alt"><span class="lnum">  23:  </span>        }</pre>
<pre><span class="lnum">  24:  </span>&nbsp;</pre>
<pre class="alt"><span class="lnum">  25:  </span>        <span class="kwrd">private</span> <span class="kwrd">void</span> CompleteIfPossible()</pre>
<pre><span class="lnum">  26:  </span>        {</pre>
<pre class="alt"><span class="lnum">  27:  </span>            <span class="kwrd">if</span> (<span class="kwrd">this</span>.Data.ProductIdsInOrder != <span class="kwrd">null</span> &amp;&amp; <span class="kwrd">this</span>.Data.CustomerHasBeenBilled)</pre>
<pre><span class="lnum">  28:  </span>            {</pre>
<pre><span class="lnum">  29:  </span>                <span class="kwrd">this</span>.Bus.Send&lt;ShipOrderToCustomer&gt;(</pre>
<pre class="alt"><span class="lnum">  30:  </span>                   (m =&gt;</pre>
<pre><span class="lnum">  31:  </span>                   {</pre>
<pre class="alt"><span class="lnum">  32:  </span>                       m.CustomerId = <span class="kwrd">this</span>.Data.CustomerId;</pre>
<pre><span class="lnum">  33:  </span>                       m.OrderId = <span class="kwrd">this</span>.Data.OrderId;</pre>
<pre class="alt"><span class="lnum">  34:  </span>                       m.ProductIdsInOrder = <span class="kwrd">this</span>.Data.ProductIdsInOrder;</pre>
<pre><span class="lnum">  35:  </span>                   }</pre>
<pre class="alt"><span class="lnum">  36:  </span>                   ));</pre>
<pre><span class="lnum">  37:  </span>                <span class="kwrd">this</span>.MarkAsComplete();</pre>
<pre class="alt"><span class="lnum">  38:  </span>            }</pre>
<pre><span class="lnum">  39:  </span>        }</pre>
<pre class="alt"><span class="lnum">  40:  </span>    }</pre>
</div>
<p>And that brings us to&#8230;</p>
<h3>Saga persistence</h3>
<p>We already saw why Shipping needs to be able to look up its internal sagas using data from the events, but what that means is that simple blob-type persistence of those sagas is out. NServiceBus comes with an NHibernate-based saga persister for exactly this reason, though any persistence mechanism which allows you to query on something other than saga Id would work just as well.</p>
<p>Let&#8217;s take a quick look at the saga data that we&#8217;ll be storing and see how simple it is:</p>
<p><!-- code formatted by http://manoli.net/csharpformat/ --></p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span>    <span class="kwrd">public</span> <span class="kwrd">class</span> ShippingSagaData : ISagaEntity</pre>
<pre><span class="lnum">   2:  </span>    {</pre>
<pre class="alt"><span class="lnum">   3:  </span>        <span class="kwrd">public</span> <span class="kwrd">virtual</span> Guid Id { get; set; }</pre>
<pre><span class="lnum">   4:  </span>        <span class="kwrd">public</span> <span class="kwrd">virtual</span> <span class="kwrd">string</span> Originator { get; set; }</pre>
<pre class="alt"><span class="lnum">   5:  </span>        <span class="kwrd">public</span> <span class="kwrd">virtual</span> Guid OrderId { get; set; }</pre>
<pre><span class="lnum">   6:  </span>        <span class="kwrd">public</span> <span class="kwrd">virtual</span> Guid CustomerId { get; set; }</pre>
<pre class="alt"><span class="lnum">   7:  </span>        <span class="kwrd">public</span> <span class="kwrd">virtual</span> List&lt;Guid&gt; ProductIdsInOrder { get; set; }</pre>
<pre><span class="lnum">   8:  </span>        <span class="kwrd">public</span> <span class="kwrd">virtual</span> <span class="kwrd">bool</span> CustomerHasBeenBilled { get; set; }</pre>
<pre class="alt"><span class="lnum">   9:  </span>    }</pre>
</div>
<p>You might have noticed the &#8220;Originator&#8221; property in there and wondered what it is for. First of all, the ISagaEntity interface requires the two properties Id and Originator. Originator is used to store the return address of the message that started the saga. Id is for what you think it&#8217;s for. In this saga, we don&#8217;t need to send any messages back to whoever started the saga, but in many others we do. In those cases, we&#8217;ll often be handling a message from some other endpoint when we want to possibly report some status back to the client that started the process. By storing that client&#8217;s address the first time, we can then &#8220;ReplyToOriginator&#8221; at any point in the process.</p>
<p>The manufacturing sample that comes with <a href="http://www.NServiceBus.com">NServiceBus</a> shows how this works.</p>
<h3>Saga Lookup</h3>
<p>Earlier, we saw the need to search for sagas based on order Id. The way to hook into the infrastructure and perform these lookups is by implementing &#8220;IFindSagas&lt;T&gt;.Using&lt;M&gt;&#8221; where T is the type of the saga data and M is the type of message. In our example, doing this using NHibernate would look like this:</p>
<p><!-- code formatted by http://manoli.net/csharpformat/ --></p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span>    <span class="kwrd">public</span> <span class="kwrd">class</span> ShippingSagaFinder : </pre>
<pre><span class="lnum">   2:  </span>        IFindSagas&lt;ShippingSagaData&gt;.Using&lt;OrderAccepted&gt;,</pre>
<pre class="alt"><span class="lnum">   3:  </span>        IFindSagas&lt;ShippingSagaData&gt;.Using&lt;CustomerBilledForOrder&gt;</pre>
<pre><span class="lnum">   4:  </span>    {</pre>
<pre class="alt"><span class="lnum">   5:  </span>        <span class="kwrd">public</span> ShippingSagaData FindBy(CustomerBilledForOrder message)</pre>
<pre><span class="lnum">   6:  </span>        {</pre>
<pre class="alt"><span class="lnum">   7:  </span>            <span class="kwrd">return</span> FindBy(message.OrderId)</pre>
<pre><span class="lnum">   8:  </span>        }</pre>
<pre class="alt"><span class="lnum">   9:  </span>&nbsp;</pre>
<pre><span class="lnum">  10:  </span>        <span class="kwrd">public</span> ShippingSagaData FindBy(OrderAccepted message)</pre>
<pre class="alt"><span class="lnum">  11:  </span>        {</pre>
<pre><span class="lnum">  12:  </span>            <span class="kwrd">return</span> FindBy(message.OrderId)</pre>
<pre class="alt"><span class="lnum">  13:  </span>        }</pre>
<pre><span class="lnum">  14:  </span>&nbsp;</pre>
<pre class="alt"><span class="lnum">  15:  </span>        <span class="kwrd">private</span> ShippingSagaData FindBy(Guid orderId)</pre>
<pre><span class="lnum">  16:  </span>        {</pre>
<pre class="alt"><span class="lnum">  17:  </span>            <span class="kwrd">return</span> sessionFactory.GetCurrentSession().CreateCriteria(<span class="kwrd">typeof</span>(ShippingSagaData))</pre>
<pre><span class="lnum">  18:  </span>                .Add(Expression.Eq(<span class="str">"OrderId"</span>, orderId))</pre>
<pre class="alt"><span class="lnum">  19:  </span>                .UniqueResult&lt;ShippingSagaData&gt;();</pre>
<pre><span class="lnum">  20:  </span>        }</pre>
<pre class="alt"><span class="lnum">  21:  </span>&nbsp;</pre>
<pre><span class="lnum">  22:  </span>        <span class="kwrd">private</span> ISessionFactory sessionFactory;</pre>
<pre class="alt"><span class="lnum">  23:  </span>&nbsp;</pre>
<pre><span class="lnum">  24:  </span>        <span class="kwrd">public</span> <span class="kwrd">virtual</span> ISessionFactory SessionFactory</pre>
<pre class="alt"><span class="lnum">  25:  </span>        {</pre>
<pre><span class="lnum">  26:  </span>            get { <span class="kwrd">return</span> sessionFactory; }</pre>
<pre class="alt"><span class="lnum">  27:  </span>            set { sessionFactory = <span class="kwrd">value</span>; }</pre>
<pre><span class="lnum">  28:  </span>        }</pre>
<pre class="alt"><span class="lnum">  29:  </span>    }</pre>
</div>
<p>For a performance boost, we&#8217;d probably index our saga data by order Id.</p>
<h3>On concurrency</h3>
<p>Another important note is that for this saga, if both messages were handled in parallel on different machines, the saga could get stuck. The persistence mechanism here needs to prevent this. When using NHibernate over a database with the appropriate isolation level (Repeatable Read &#8211; the default in NServiceBus), this &#8220;just works&#8221;. If/When implementing your own saga persistence mechanism, it is important to understand the kind of concurrency your business logic can live with.</p>
<p>Take a look at Ayende&#8217;s example for <a href="http://ayende.com/Blog/archive/2009/01/23/rhino-dht-concurrency-handling-example-ndash-the-phone-billing-system.aspx">mobile phone billing</a> to get a feeling for what that&#8217;s like.</p>
<h3>Summary</h3>
<p>In almost any event-driven architecture, you&#8217;ll have services correlating multiple events in order to make decisions. The saga pattern is a great fit there, and not at all difficult to implement. You do need to take into account that events may arrive out of order and implement the saga logic accordingly, but it&#8217;s really not that big a deal. Do take the time to think through what data will need to be stored in order for the saga to be fault-tolerant, as well as a persistence mechanism that will allow you to look up that data based on event data.</p>
<p>If you feel like giving this approach a try, but don&#8217;t have an environment handy for this, download <a href="http://www.NServiceBus.com">NServiceBus</a> and take a look at the samples. It&#8217;s really quick and easy to get set up.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2009/04/20/saga-persistence-and-event-driven-architectures/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>NServiceBus 1.9 RTM</title>
		<link>http://www.udidahan.com/2009/04/15/nservicebus-19-rtm/</link>
		<comments>http://www.udidahan.com/2009/04/15/nservicebus-19-rtm/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 10:07:46 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[NServiceBus]]></category>

		<guid isPermaLink="false">http://www.udidahan.com/?p=990</guid>
		<description><![CDATA[After an additional 3 months of stability seen on the release candidate, I&#8217;m happy to say that nServiceBus has now reached a full version 1.9 release. 
Very little has changed, so the version 1.9 story described here is still accurate.
Just last week one of my clients went live with a rollout to one of the [...]]]></description>
			<content:encoded><![CDATA[<p>After an additional 3 months of stability seen on the release candidate, I&#8217;m happy to say that nServiceBus has now reached a full version 1.9 release. </p>
<p>Very little has changed, so the version 1.9 story described <a href="http://www.udidahan.com/2009/02/07/nservicebus-19/">here</a> is still accurate.</p>
<p>Just last week one of my clients went live with a rollout to one of the world&#8217;s biggest names in the hospitality industry and things are looking good. Since stability is such a big deal to them (and many of my other clients), they&#8217;ve rolled out on nServiceBus 1.8 but now are ready to make the move to 1.9. Hopefully we&#8217;ll be able to get a case study out of them <img src='http://www.udidahan.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>For more information, go to the <a href="http://www.NServiceBus.com">NServiceBus site</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2009/04/15/nservicebus-19-rtm/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>NServiceBus 1.9</title>
		<link>http://www.udidahan.com/2009/02/07/nservicebus-19/</link>
		<comments>http://www.udidahan.com/2009/02/07/nservicebus-19/#comments</comments>
		<pubDate>Sat, 07 Feb 2009 20:13:28 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[NServiceBus]]></category>

		<guid isPermaLink="false">http://www.udidahan.com/2009/02/07/nservicebus-19/</guid>
		<description><![CDATA[It&#8217;s been about 6 months since my last post on nServiceBus. In that time about 1000 people have subscribed to this blog and many of them don&#8217;t know anything about it. Also, version 1.9 of nServiceBus appears to be solid enough to drop its &#8220;release candidate&#8221; qualification so this seems like a good time for [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been about 6 months since my last post on nServiceBus. In that time about 1000 people have subscribed to this blog and many of them don&#8217;t know anything about it. Also, version 1.9 of nServiceBus appears to be solid enough to drop its &#8220;release candidate&#8221; qualification so this seems like a good time for this kind of post.<a title="NServiceBus" href="http://www.nservicebus.com"><img style="border-right: 0px; border-top: 0px; margin: 0px 5px 10px 10px; border-left: 0px; border-bottom: 0px" height="73" alt="nServiceBus_banner_2" src="http://www.udidahan.com/wp-content/uploads/nservicebus-banner-2.png" width="244" align="right" border="0"></a> </p>
<h3>What is it?</h3>
<p>From the <a href="http://www.nservicebus.com/">NServiceBus.com</a> site:</p>
<blockquote><p>&#8220;NServiceBus is a powerful, yet lightweight, open source messaging framework <br />for designing distributed .NET enterprise systems. Entirely pluggable yet simple to use, NServiceBus gives programmers a head-start on developing robust, scalable, <br />and maintainable service-layers and long-running business processes.&#8221;</p>
</blockquote>
<p>One of the developers who downloaded nServiceBus, Jürgen, sent me this in an email:</p>
<blockquote><p>&#8220;I took the samples, swapped in my own code, and had a machines subscribing, publishing, messaging, in like 15 minutes. </p>
<p>I&#8217;ve got to tell you &#8211; from reading the architecture stuff on your blog I always thought this stuff was going to be hard. I know you always say its supposed to be simple but I never really believed it. I mean, seriously, if I had to do this stuff with web services or WCF &#8211; well, I wouldn&#8217;t know where to begin.&#8221;</p>
</blockquote>
<p>(His English totally surprised me &#8211; not what you&#8217;d expect from someone called Jürgen. Born in Sweden but grew up in the US.)</p>
<p>BTW, <a href="http://samgentile.com/Web/neuron-esb/enterprise-service-buses-esbs-drive-soa-adoption-part-4/">Sam&#8217;s showed where to begin with WCF:</a> basic pub/sub without durability is 480 LOC. </p>
<h3>What&#8217;s different &#8211; Containers</h3>
<p>People who looked at earlier versions of nServiceBus will see many incremental improvements that smooth over previously rough parts of the framework.</p>
<p>Chris Patterson, co-founder of MassTransit mentioned one such area in his <a href="http://www.lostechies.com/blogs/chris_patterson/archive/2008/12/26/masstransit-turns-one-year-old-celebrations-held-around-the-world.aspx">blog post</a>:</p>
<blockquote><p>&#8220;Both Dru and I needed a framework for asynchronous messaging to address some work-related application requirements. While MSMQ is provided out of the box [on Windows], it doesn&#8217;t directly encourage some good distributed application practices such a loose coupling. Our goal was to abstract the messaging aspects so the services could be built to deal with plain old objects (POCOs) instead of lower level transport messages.</p>
<p>Originally, we both looked at <a href="http://www.nservicebus.com/">NServiceBus</a> as a way to make this happen. I&#8217;ve followed Udi&#8217;s blog for a while and have really gained a lot of knowledge from his posts and presentations. However, our lack of experience in Spring.NET, along with a general lack of understanding of all the complexity of such a framework led us down the path of building our own framework.&#8221;</p>
</blockquote>
<p>Version 1.9 takes a totally different approach (than v1.6/1.7 at which I believe Chris was looking back then) to dependency injection frameworks (like Spring.NET) and decreases their footprint. Developers don&#8217;t need to know anything about Spring, Castle, or any other container to get started, but always have the ability to configure it however they want and even swap in their container of choice.</p>
<h3>What&#8217;s different &#8211; DLL Footprint</h3>
<p>Another difference is the number of assemblies that come with nServiceBus. Nathan Stults had <a href="http://www.thefreakparade.com/2008/06/simple-service-bus-on-codeplex-a-fork-of-nservicebus/">this to say</a> about version 1.8:<br />
<blockquote>
<p>&#8220;NServiceBus (for valid architectural reasons) is split up into eleven thousand, two hundred and nine different DLL’s. That may be an exaggeration, but many of the dll’s have only one or two code files in them, with only a few lines of code each.&#8221;</p>
</blockquote>
<p>NServiceBus has always supported swapping out various technological implementations and will continue do so. For that reason, the development environment is organized into 79 projects whose dependencies are managed very strictly. As of version 1.9, most of these assemblies including many supporting libraries like Spring and Castle have been merged into NServiceBus.dll. There&#8217;s also NServiceBus.Testing.dll which supports fluent-unit-testing entire business processes.
<p>There is one non-optional external dependency which hasn&#8217;t been merged and that is log4net &#8211; although if you configure in a Common.Logging provider to your own logging infrastructure, you can do without it as well. With log4net, the minimum deployment footprint is 2 assemblies. The other dependency which <em>is</em> optional is NHibernate. The reason for leaving these out is that many teams depend on specific versions of those assemblies.
<p>In short &#8211; you reference ONE assembly. Just one.<br />
<h3>&nbsp;</h3>
<h3>What else?</h3>
<p>There is quite a lot in there. Ayende&#8217;s put out several posts describing those features and similarities to the bus he&#8217;s working on:</p>
<ul>
<li><a href="http://ayende.com/Blog/archive/2009/01/14/rhino-service-bus-managing-timeouts.aspx">Managing Timeouts</a></li>
<li><a href="http://ayende.com/Blog/archive/2009/01/16/rhino-service-bus-saga-and-state.aspx">Long-running processes</a></li>
<li><a href="http://ayende.com/Blog/archive/2008/03/24/NServiceBus-Distributor-Review.aspx">Load Balancing</a></li>
</ul>
<p>Ayende&#8217;s description of the NServiceBus load-balancing capability was:</p>
<blockquote><p>&#8220;The distributor section of NServiceBus is a thing of beauty.&#8221;</p>
</blockquote>
<h3>Performance</h3>
<p>You may be surprised by the kind of performance we&#8217;re able to wring out of &#8220;basic&#8221; MSMQ. Keep in mind, though, that you can swap in your own transport &#8211; there are already some others out there on the <a href="http://code.google.com/p/nservicebus-contrib/">Contrib site</a> including ActiveMQ and shared memory.</p>
<p>The most thorough performance numbers I&#8217;ve seen on nServiceBus have been written up <a href="http://www.udidahan.com/2008/05/21/nservicebus-performance/">here</a>:</p>
<blockquote><p>&#8220;total throughput over 1 billion messages an hour. That was about 100 million per hour durable, 900 million per hour non-durable&#8221;</p>
</blockquote>
<p>This was on an 3 blade centers (48 blades), 30 pizza boxes (1U), and 20 clusters, version 1.8.</p>
<p>On <a href="http://gojko.net/2008/12/02/asynchronous-net-applications-with-nservicebus/">Gojko&#8217;s blog</a> there is a video of talk on nServiceBus where Dave de Florinier mentioned throughputs of 600,000 messages per hour (no mention of supporting hardware) and I think it was version 1.7 or 1.8 of nServiceBus.</p>
<p>Recently, Raymond Lewallen posted his numbers for 1.9 to the <a href="http://tech.groups.yahoo.com/group/nservicebus/message/1791">discussion group</a>:</p>
<blockquote><p>&#8220;We load tested our full duplex and pub/sub scenarios the other day at about 500 messages per second with no hiccups at all.&#8221; (save yourself the math, its 1.8M/hr)</p>
</blockquote>
<p>The really interesting numbers are coming in from one of my clients (on 1.9) where the focus is on business process (saga) throughput where they&#8217;re seeing millions completing each day on top of IO intensive technical processes. I&#8217;m excited.</p>
<h3>Looking forward</h3>
<p>After working with clients using nServiceBus over 4 years now (even before it was open source or had a real name), it just keeps getting better. It&#8217;s also really great to see more open source projects coming on the scene &#8211; MassTransit (<a href="http://www.lostechies.com/blogs/chris_patterson/archive/2008/12/26/masstransit-turns-one-year-old-celebrations-held-around-the-world.aspx">now a year old</a>), and <a href="http://ayende.com/Blog/archive/2008/12/17/rhino-service-bus.aspx">Rhino Service Bus</a> (young, but in production with NH-Prof). </p>
<p>The mutual <strike>stealing</strike> cross-pollination is increasing the pace all around.</p>
<p>I intend to take up <a href="http://code.google.com/p/topshelf/">TopShelf</a> (which came out of MassTransit) as the generic service host. That combined with the robust distributor hosting model will make &#8220;grid-friendly&#8221; nServiceBus endpoints much easier. Ayende&#8217;s posts about automatically creating queues and other &#8220;first-time-developer&#8221; features have really worked to decrease the nServiceBus learning curve &#8211; and it shows.</p>
<p>Documentation is a notorious problem in open-source projects and nServiceBus hasn&#8217;t escaped it. API and internal documentation is only now getting close to 100% and the samples now give developers a good start on using it. Those developers looking at swapping out certain bits of functionality have a harder time, but that&#8217;s slowly improving as well. The <a href="http://tech.groups.yahoo.com/group/nservicebus/">discussion group</a> is the best place to get those hard-to-find answers now with a community over 200 strong.</p>
<p>The difficulty developers have in adopting nServiceBus is giving up &#8220;request/response&#8221; thinking. This requires an adjustment to a system&#8217;s architecture and is what most of this blog has been about. Conversely, if you have been following this blog and this thinking resonates with you, you&#8217;ll find it very simple and straight-forward. The <a href="http://www.nservicebus.com/Overview.aspx">overview page</a> on NServiceBus.com also gives a good description of messaging basics &#8211; stuff that I&#8217;ve kind of glossed over on this blog so far.</p>
<p>Go on then. <strong><a href="http://www.nservicebus.com">Take it for a spin</a></strong>. Write a review. Sam Gentile had <a href="http://samgentile.com/blogs/samgentile/archive/2008/06/24/looking-at-nservicebus-added-to-tonight-s-presentation.aspx">this to say</a> about v1.8:</p>
<blockquote><p>&#8220;The bottom line is: I like what I see. Although it&#8217;s a framework, not an ESB product like Neuron, it&#8217;s a powerful framework that takes the right approach on SOA and enforces a paradigm of reliable one-way, *non-blocking* calls.&#8221;</p>
</blockquote>
<p>Can&#8217;t wait to hear the response to 1.9.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2009/02/07/nservicebus-19/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Command Query Separation and SOA</title>
		<link>http://www.udidahan.com/2008/08/11/command-query-separation-and-soa/</link>
		<comments>http://www.udidahan.com/2008/08/11/command-query-separation-and-soa/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 13:18:40 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Autonomous Services]]></category>
		<category><![CDATA[Messaging]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Pub/Sub]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Smart Client]]></category>

		<guid isPermaLink="false">http://www.udidahan.com/2008/08/11/command-query-separation-and-soa/</guid>
		<description><![CDATA[One of the common questions I receive from people starting to use nServiceBus is how one-way messaging fits with showing the user a grid (or list) of data. Thinking about publish/subscribe usually just gets them even more confused. Trying to resolve all this with Service Oriented Architecture leaves them wondering &#8211; why bother?

In regular client-server [...]]]></description>
			<content:encoded><![CDATA[<p>One of the common questions I receive from people starting to use nServiceBus is how one-way messaging fits with showing the user a grid (or list) of data. Thinking about publish/subscribe usually just gets them even more confused. Trying to resolve all this with Service Oriented Architecture leaves them wondering &#8211; why bother?</p>
<p><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="267" alt="client server" src="http://www.udidahan.com/wp-content/uploads/image38.png" width="477" border="0" /></p>
<p>In regular client-server development, the server is responsible for providing the client with all CRUD (create, read, update, and delete) capabilities. However, when users look at data they do not often require it to be up to date to the second (given that they often look at the same screen for several seconds to minutes at a time). As such, retrieving data from the same table as that being used for highly consistent transaction processing creates contention resulting in poor performance for all CRUD actions under higher load.</p>
<h4>A Scalable Solution </h4>
<p>One of the common answers to this question is for the server/service to publish a message when data changes (say, as the result of processing a message) and for clients to subscribe to these messages. When such a notification arrives at a client, the client would cache the data it needs. Then, when the user wants to see a grid of data, that data is already on the client. Of course, this solution doesn&#8217;t work so well for older client machines (like some point of service devices) or if there are millions of rows of data.</p>
<p>The thing is that this solution is one implementation of a more general pattern &#8211; command query separation (CQS).</p>
<h4>Command Query Separation</h4>
<p>Wikipedia <a href="http://en.wikipedia.org/wiki/Command-query_separation">describes</a> CQS as a pattern where &quot;&#8230; every method should either be a <i>command</i> that performs an action, or a <i>query</i> that returns data to the caller, but not both. More formally, methods should return a value only if they are referentially transparent and hence possess no side effects.&quot;</p>
<p>Martin Fowler is less strict about the use of CQS <a href="http://martinfowler.com/bliki/CommandQuerySeparation.html">allowing for exceptions</a>: &quot;Popping a stack is a good example of a modifier that modifies state. Meyer correctly says that you can avoid having this method, but it is a useful idiom. So I prefer to follow this principle when I can, but I&#8217;m prepared to break it to get my pop.&quot;</p>
<p>So, how does separating commands from queries and SOA help at all in getting data to and from a UI? The answer is based on Pat Helland&#8217;s thinking as described in his article <a href="http://msdn.microsoft.com/en-us/library/ms954587.aspx">Data on the Inside vs. Data on the Outside</a>.</p>
<h4>Services Cross Boxes </h4>
<p>The biggest lie around SOA is that services run.</p>
<p>Let that sink in a second.</p>
<p>Sure services have runnable components, but that&#8217;s not why they&#8217;re important. </p>
<p>I&#8217;ll skip the <a href="http://www.udidahan.com/first-time-here/#soa">books of background</a> and cut to the chase:</p>
<blockquote><p>Services communicate with each other using publish/subscribe and one-way messaging. Services have components inside them. Inside a service, these components can communicate with each using synchronous RPC, or any other mechanism. Also, <em>these components can reside on different machines</em>.</p>
</blockquote>
<p>This is broader than just scaling out a service. There can be service components running on the client as well as the server.</p>
<h4>SOA &amp; CQS</h4>
<p>Combining these two concepts together, here&#8217;s what comes out:</p>
<p><img src="http://www.nservicebus.com/img/CQS.png" /> </p>
<p>In this solution there are two services that span both client and server &#8211; one in charge of commands (create, update, delete), the other in charge of queries (read). These services communicate only via messages &#8211; one cannot access the database of the other. </p>
<p>The command service publishes messages about changes to data, to which the query service subscribes. When the query service receives such notifications, it saves the data in its own data store which may well have a different schema (optimized for queries like a star schema).</p>
<p>The client component which is in charge of showing grids of data to the user behaves the same as it would in a regular layered/tiered architecture, using synchronous blocking request/response to get its data &#8211; SOA doesn&#8217;t change that.</p>
<h4>Composite Applications </h4>
<p>Although the client side components of both the command and query services are hosted in the same process, they are very much independent of each other. That being said, from an interoperability perspective (the one that most people attribute to SOA), all of the client-side components will likely be developed using the same technology &#8211; although there are already ways to <a href="http://www.udidahan.com/2007/05/28/netjava-interop-is-not-a-reason-for-soa/">host Java code in .NET</a> and vice-versa. </p>
<p>Of course, once we talk about web UI&#8217;s things are a bit different &#8211; but still similar. While web-server-side there may be a level of independence, for browser side inter-component communications we&#8217;re still likely to target javascript. There, I&#8217;ve managed to say something technical supporting mashups and SOA without lying through my teeth.</p>
<p>On the Microsoft side with the recent release of the Composite Application Guidance &amp; Library (pronounced &quot;<a href="http://www.codeplex.com/CompositeWPF">prism</a>&quot;) I hope that more of these principles will be reaching the &quot;smart client&quot;. The command pattern is especially critical in maintaining the separation while enabling communication to still occur so I&#8217;m glad that, as one of the Prism advisors, I was able to simplify that part (<a href="http://codebetter.com/blogs/glenn.block/">Glenn</a> still has nightmares about that rooftop conversation).</p>
<h4>Publish / Subscribe</h4>
<p>In the &quot;scalable solution&quot; section up top I mentioned how publish/subscribe to the smart client is really just one implementation of CQS and SOA. So, how different is it really?</p>
<p><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="241" alt="smart client pub/sub" src="http://www.udidahan.com/wp-content/uploads/image39.png" width="554" border="0" /> </p>
<p>Well, there will probably be a different technology mapping. Instead of a star-schema OLAP product, we might simply store the published data in memory on the client. That is, if you designed your components to be technology agnostic.</p>
<p>In terms of the use of nServiceBus, the same component is going to be subscribing to the same type of message &#8211; all that&#8217;s different is that now every client will be having data pushed to them rather than this occurring server-side only. </p>
<p>You could have the same code deployed differently in the same system &#8211; stronger clients subscribing themselves, weaker ones using a remote server. Web servers would probably be considered stronger clients. This kind of flexible deployment has proven to be extremely valuable for my larger clients. The added benefit of enabling users to work (view data) even while offline (somewhere there&#8217;s no WIFI) is just icing on the cake.</p>
<h4>A Word of Warning</h4>
<p>Once the client starts receiving notifications, and handling those on a background thread (as it should) the code becomes susceptible to deadlocks and data races. Juval does a good job of outlining <a href="http://www.udidahan.com/2008/04/11/wcf-smart-clients-and-deadlocks/">some of those</a> with respect to the use of WCF. Prism <a href="http://www.udidahan.com/2008/06/09/prism-occasionally-connected/">doesn&#8217;t provide any assurances</a> in this area either.</p>
<h4>Summary</h4>
<p>NServiceBus is not designed to be used for any and all types of communication in a given architecture. In the examples above, nServiceBus handles the publish/subscribe but leaves the synchronous RPC to existing solutions like WCF. Not only that, but synchronous RPC does have its place in architecture, just not across service boundaries. In all cases, data is served to users from a store different from that which transaction processing logic uses.</p>
<p>Command Query Separation is not only a good idea at the method/class level but has advantages at the SOA/System level as well &#8211; yet another good idea from 20 years ago that services build upon. Making use of CQS requires understanding your data and its uses &#8211; SOA builds on that by looking into data volatility and the freshness business requirements around it.</p>
<p>Finally, designing the components of your services in such a way that their dependency on technology is limited buys a lot of flexibility in terms of deployment and, consequently, significant performance and scalability gains.</p>
<p>Simple, it is. Easy, it is not.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2008/08/11/command-query-separation-and-soa/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Make WCF and WF as Scalable and Robust as NServiceBus</title>
		<link>http://www.udidahan.com/2008/06/30/make-wcf-and-wf-as-scalable-and-robust-as-nservicebus/</link>
		<comments>http://www.udidahan.com/2008/06/30/make-wcf-and-wf-as-scalable-and-robust-as-nservicebus/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 14:47:08 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Reliability]]></category>
		<category><![CDATA[Scalability]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/06/30/make-wcf-and-wf-as-scalable-and-robust-as-nservicebus/</guid>
		<description><![CDATA[This topic is getting more play as more people are using WCF and WF in real-world scenarios, so I thought I&#8217;d pull the things that I&#8217;ve been watching in this space together:
Reliability 
Locking in SqlWorkflowPersistenceService (via Ron Jacobs) where, if you want predictable persistence (MS: &#8216;none of our customers asked for this to be easy&#8217;), [...]]]></description>
			<content:encoded><![CDATA[<p>This topic is getting more play as more people are using WCF and WF in real-world scenarios, so I thought I&#8217;d pull the things that I&#8217;ve been watching in this space together:</p>
<h3>Reliability<a href="http://udidahan.weblogs.us/wp-content/uploads/doctor1.png"><img style="border-right: 0px; border-top: 0px; margin: 0px 0px 10px 10px; border-left: 0px; border-bottom: 0px" height="244" alt="doctor" src="http://udidahan.weblogs.us/wp-content/uploads/doctor-thumb1.png" width="225" align="right" border="0"></a> </h3>
<p><a href="http://blogs.msdn.com/rjacobs/archive/2008/06/27/locking-in-sqlworkflowpersistenceservice.aspx">Locking in SqlWorkflowPersistenceService</a> (via Ron Jacobs) where, if you want predictable persistence (MS: &#8216;none of our customers asked for this to be easy&#8217;), you need to use a custom activity (which Ron was kind enough to supply).</p>
<blockquote><p>&#8220;Given what I learned today I&#8217;d have to say that I&#8217;d be very careful about using workflows with an optimistic locking.&nbsp; Detecting these types of situations is not that simple.&#8221;</p>
</blockquote>
<p>Let&#8217;s think about that. If we&#8217;re doing pessimistic locking, we get into the problem of, if a host restarts (as the result of a critical windows patch or some other unexpected occurrence), that the workflow won&#8217;t be able to be handled by any other host in the meantime (you didn&#8217;t care so much about your SLA, did you?).</p>
<p>Luckily, someone&#8217;s come up with a hack that works around this robustness problem in <a href="http://www.topxml.com/rbnews/Orchestration---Workflow/re-78382_Scaleable-Workflow-Persistence-and-Ownership.aspx">Scalable Workflow Persistence and Ownership</a>.</p>
<blockquote><p>&#8220;So this code will attempt to load workflow instances with expired locks every second. Is it a hack? Yes. But without one of two things in the SqlWorkflowPersistenceService its the sort of code you have to write to pick up unlocked workflow instances robustly.&#8221;</p>
</blockquote>
<p>This will seriously churn the table used to store your workflows, decreasing performance of workflows that haven&#8217;t timed out. Oh well.</p>
<h3>Testability</h3>
<p><a href="http://blogs.msdn.com/ploeh/archive/2008/06/26/implementing-wcf-services-without-referencing-wcf.aspx">Implementing WCF Services without Referencing WCF</a> (via Mark Seemann): </p>
<blockquote><p>&#8220;More than a year ago, I wrote my first post on <a href="http://blogs.msdn.com/ploeh/archive/2006/12/03/UnitTestingWCFServices.aspx">unit testing WCF services</a>. One of my points back then was that you have to be careful that the service implementation doesn&#8217;t use any of the services provided by the WCF runtime environment (if you want to keep the service testable). As soon as you invoke something like <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.operationcontext.current.aspx">OperationContext.Current</a>, your code is not going to work in a unit testing scenario, but only when hosted by WCF.&#8221;</p>
</blockquote>
<p>After pointing out some of the more basic difficulties in testability a straightforward WCF implementation brings, Mark turns the heat up in his follow-up post, <a href="http://blogs.msdn.com/ploeh/archive/2008/06/27/modifying-behavior-of-wcf-free-service-implementations.aspx">Modifying Behavior of WCF-Free Service Implementations</a>:</p>
<blockquote><p>&#8220;Perhaps you need to control the service&#8217;s <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.servicebehaviorattribute.concurrencymode.aspx">ConcurrencyMode</a>, or perhaps you need to set <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.servicebehaviorattribute.usesynchronizationcontext.aspx">UseSynchronizationContext</a>. These options are typically controlled by the <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.servicebehaviorattribute.aspx">ServiceBehaviorAttribute</a>. You may also want to provide an <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.iinstanceprovider.aspx">IInstanceProvider</a> via a custom attribute that implements <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.description.icontractbehavior.aspx">IContractBehavior</a>. However, you can&#8217;t set these attributes on the service implementation itself, since it mustn&#8217;t have a reference to System.ServiceModel.&#8221;</p>
</blockquote>
<p>Wow &#8211; all the things required to make a WCF service scalable and thread-safe make it difficult to test. In the end, we&#8217;re beginning to see how many hoops we have to go through in order to get separation of concerns, but until we can take all this and get it out of our application code, it&#8217;s an untenable solution. I hope Mark will continue with this series, if only so I can take the framework that might grow out of it and use it as a generic WCF transport for NServiceBus.</p>
<h3>Comparison<a href="http://udidahan.weblogs.us/wp-content/uploads/apples-and-oranges.jpg"><img style="border-right: 0px; border-top: 0px; margin: 0px 0px 10px 10px; border-left: 0px; border-bottom: 0px" height="244" alt="apples and oranges" src="http://udidahan.weblogs.us/wp-content/uploads/apples-and-oranges-thumb.jpg" width="184" align="right" border="0"></a> </h3>
<p>After the <a href="http://samgentile.com/blogs/samgentile/archive/2008/05/21/response-to-nservicebus-performance.aspx">Neuron-NServiceBus comparison</a> that Sam and I had, we talked some more. After going through some of the rational and thinking, Sam even <a href="http://samgentile.com/blogs/samgentile/archive/2008/06/24/looking-at-nservicebus-added-to-tonight-s-presentation.aspx">put nServiceBus into his WCF-Neuron comparison talk</a>. Sam had this to say about nServiceBus:</p>
<blockquote><p>&#8220;The bottom line is: I like what I see. Although it&#8217;s a framework, not an ESB product like Neuron, it&#8217;s a powerful framework that takes the right approach on SOA and enforces a paradigm of reliable one-way, *non-blocking* calls. That is the point of the talk tonight overall; we need to get away from the stack world of synchronous RPC calls to true asynchronous non-blocking message based SOA systems.&#8221;</p>
</blockquote>
<p>The main concern I have with a WCF+WF based solution is that developers need to know a lot in order to make it testable, scalable, and robust. In nServiceBus, that&#8217;s baked into the design. It would be extremely difficult for a developer writing application logic to interfere with when persistence needs to happen, or the concurrency strategy of long-running workflows. The fact that message handlers in the service layer don&#8217;t need concurrency modes, instance providers, or any of that junk make them testable by default.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2008/06/30/make-wcf-and-wf-as-scalable-and-robust-as-nservicebus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sagas Solve Stupid Transaction Timeouts</title>
		<link>http://www.udidahan.com/2008/06/23/sagas-solve-stupid-transaction-timeouts/</link>
		<comments>http://www.udidahan.com/2008/06/23/sagas-solve-stupid-transaction-timeouts/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 07:09:31 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Scalability]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/06/23/sagas-solve-stupid-transaction-timeouts/</guid>
		<description><![CDATA[It turns out that there was a subtle, yet dangerous problem in the use of System.Transactions &#8211; a transaction could timeout, rollback, and the connection bound to that transaction could still change data in the database.  
Think about that a second.
Scary, isn&#8217;t it?
At TechEd Israel I had a discussion with Manu on this very [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://weblogs.asp.net/ryangaraygay/archive/2008/04/14/issue-with-system-transactions-sqlconnection-and-timeout.aspx">It turns out</a> that there was a subtle, yet dangerous problem in the use of System.Transactions &#8211; a transaction could timeout, rollback, and the connection bound to that transaction could still change data in the database. <a href="http://udidahan.weblogs.us/wp-content/uploads/image25.png"><img style="border-right: 0px; border-top: 0px; margin: 0px 0px 10px 10px; border-left: 0px; border-bottom: 0px" height="117" alt="image" src="http://udidahan.weblogs.us/wp-content/uploads/image-thumb21.png" width="84" align="right" border="0"></a> </p>
<p>Think about that a second.</p>
<p>Scary, isn&#8217;t it?</p>
<p>At TechEd Israel I had a discussion with <a href="http://blogs.microsoft.co.il/blogs/applisec/">Manu</a> on this very issue, just under a different hat: </p>
<blockquote><p>What&#8217;s the difference between a short-running workflow and a long-running one?</p>
</blockquote>
<p>Manu suggested that we look at the actual time that things ran to differentiate between them. I asserted that if any external communication was involved in some part of state-management logic, that logic should automatically be treated as long-running.</p>
<p>Manu&#8217;s reasoning was that the complexity involved in writing long-running workflows was not justified for things that ran quickly, even if there was communication involved. Many developers don&#8217;t think twice about synchronously calling some web services in the middle of their database transaction logic. In the many Microsoft presentations I&#8217;ve been at on WF, not once has it been mentioned that state machines should be used when external communication is involved.</p>
<p>The problem that I have with this guidance is how do you know how quickly a remote call will return?</p>
<p>Do you just run it all locally on your machine, measure, and if it doesn&#8217;t take more than a second or so, then you&#8217;re OK?</p>
<p>The fact of the matter is that we can never know what the response time of a remote call will be. Maybe the remote machine is down. Maybe the remote process is down. Maybe someone changed the firewall settings and now we&#8217;re doing 10KB/s instead of 10MB/s. Maybe the local service is down and we&#8217;re communicating with the backup on the other side of the Pacific Ocean.</p>
<p>But the thing is, Manu&#8217;s right.</p>
<p>Writing long-running workflows (with WF) is more complex than is justified. My guess is that since WF wasn&#8217;t specifically designed for long-running workflows <em>only</em>, that this complexity crept in.<a href="http://www.nServiceBus.com"><img style="border-right: 0px; border-top: 0px; margin: 0px 0px 10px 10px; border-left: 0px; border-bottom: 0px" height="43" alt="nservicebus_logo_small" src="http://udidahan.weblogs.us/wp-content/uploads/nservicebus-logo-small.png" width="153" align="right" border="0"></a></p>
<p>Sagas in <a href="http://www.nServiceBus.com">nServiceBus</a> <em>were</em> specifically designed for long-running workflows only. </p>
<p>Maybe that&#8217;s what kept them simple.</p>
<p>Since all external communication is done via one-way, non-blocking messaging only, each step of a saga runs as quick as if no communication were done at all. This keeps the time the transaction in charge of handling a message is open as short as possible. That, in turn, leads to the database being able to support more concurrent users. </p>
<p>In short, sagas are both more scalable and more robust.</p>
<p>No need to worry about garbaging-up your database.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2008/06/23/sagas-solve-stupid-transaction-timeouts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Architecture &amp; Design World 2008</title>
		<link>http://www.udidahan.com/2008/05/31/architecture-design-world-2008/</link>
		<comments>http://www.udidahan.com/2008/05/31/architecture-design-world-2008/#comments</comments>
		<pubDate>Sat, 31 May 2008 11:23:48 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Presentations]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/05/31/architecture-design-world-2008/</guid>
		<description><![CDATA[In the vein of my previous post, I&#8217;ll be coming back to the States a month after TechEd for Dr. Dobb&#8217;s Architecture &#38; Design World 2008.
I&#8217;ll be giving my Avoid a Failed SOA talk (again). Apparently, I&#8217;m not the only one who&#8217;s been seeing one SOA project fail after another. Luckily, I&#8217;ve lived through enough [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://drdobbsarchworld.com/index.php?option=com_content&amp;task=view&amp;id=5&amp;Itemid=42"><img style="margin: 0px 5px 10px 10px" src="http://drdobbsarchworld.com/images/stories/seemead08.gif" align="right" border="0"></a>In the vein of my previous post, I&#8217;ll be coming back to the States a month after TechEd for Dr. Dobb&#8217;s Architecture &amp; Design World 2008.</p>
<p>I&#8217;ll be giving my Avoid a Failed SOA talk (again). Apparently, I&#8217;m not the only one who&#8217;s been seeing one SOA project fail after another. Luckily, I&#8217;ve lived through enough of them to figure out what sort of things empirically have lead to failure, and now I&#8217;m telling the tale. One of the big reasons, by the way, is calling everything in the system a service (and no, adding a prefix doesn&#8217;t change anything &#8211; entity services, process services, etc).</p>
<p>I&#8217;m also going to be speaking about core design principles in my Intentions &amp; Interfaces talk (which was quite a hit at QCon London). The interesting thing I&#8217;ve discovered over the years about design is that generics and dependency injection, when used together, can be used to create extensible systems with very little complexity. Not only that, but that this pattern is useful for all parts of a system, from communication, through data access, all the way to custom validation. As such, it can keep the complexity of the various technology stacks out of your core business logic, giving it a longer lease on life.</p>
<p>Finally, there&#8217;s also going to be a half-day tutorial on nServiceBus. I don&#8217;t want to go on-and-on about it here, but I can say that people who have attended this tutorial have come to me later telling me how they feel that they&#8217;ve had their eyes opened. I try to give just enough theory so that attendees can understand why nServiceBus exists, because after that using nServiceBus is pretty straight forward. This will be the first time I&#8217;m doing this in half-day format, so you&#8217;ll be getting the bottom-line, distilled version of this regularly full-day tutorial.</p>
<p>You can find the list of all my talks <a href="https://www.cmpevents.com/SDUM8/a.asp?option=G&amp;V=3&amp;id=536365">here</a>, and for being the loyal reader you are, you get $100 bucks off the VIP price when you <a href="http://drdobbsarchworld.com/index.php?option=com_content&amp;task=view&amp;id=5&amp;Itemid=42">register</a> using the code 8ASPK.</p>
<p>Hope to see you there. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2008/05/31/architecture-design-world-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NServiceBus Performance</title>
		<link>http://www.udidahan.com/2008/05/21/nservicebus-performance/</link>
		<comments>http://www.udidahan.com/2008/05/21/nservicebus-performance/#comments</comments>
		<pubDate>Wed, 21 May 2008 07:08:05 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[ESB]]></category>
		<category><![CDATA[MSMQ]]></category>
		<category><![CDATA[Messaging]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Scalability]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/05/21/nservicebus-performance/</guid>
		<description><![CDATA[I&#8217;ve gotten this question several times already but now companies are beginning to look for performance comparisons in making decisions around the use of nServiceBus. It&#8217;s often compared to straight WCF, BizTalk, and now Neuron ESB. In Sam&#8217;s recent post he posts to a case study of Neuron doing 28 million messages an hour. That&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve gotten this question several times already but now companies are beginning to look for performance comparisons in making decisions around the use of nServiceBus. It&#8217;s often compared to straight WCF, BizTalk, and now Neuron ESB. In Sam&#8217;s <a href="http://samgentile.com/blogs/samgentile/archive/2008/05/19/new-and-notable-243.aspx">recent post</a> he posts to a case study of Neuron doing 28 million messages an hour. That&#8217;s far more than I&#8217;ve ever heard quoted for BizTalk.</p>
<h3>Disclaimer</h3>
<p>Before giving some numbers, please keep in mind that high performance of system infrastructure does not necessarily by itself mean that the system above it is running that fast. For instance, you may have server heartbeats running really quickly but the time it takes to save a purchase order borders on a minute. So, please, take all benchmarks with a grain of salt, or two, or a whole shaker-full.</p>
<p>While I&#8217;m not at liberty to say on which specific domain/company these numbers were measured, I can say that we had the full gamut of &#8220;stateless services&#8221;, statefull services (sagas), number crunching, large data sets, many users, complex visualization, etc. Also, this wasn&#8217;t the largest installation of nServiceBus that I&#8217;m aware of, but its the one I have the most specific numbers for.</p>
<h3>Setup</h3>
<p>OK, so using the default nServiceBus distribution using MSMQ, on servers where the queue files themselves were on separate SCSI RAID disks, we were pumping around 1000 durable, transactionally processed messages per second, per server. That means that similar to the Neuron case, no messages would be lost in the case of a single fault per server per window (time to replace a failed disk set at 3 hours from failure, through detection, to replacement per site &#8211; but that&#8217;s more an operational staffing concern, not the technology itself). </p>
<p>So, that&#8217;s 3.6 million messages per hour per server, at full load. We had a total of 98 servers doing these kinds of processing, not including web servers, databases, etc. Keep in mind that web servers would be communicating with other servers using nServiceBus, but that would maybe be an unfair comparison to the Neuron numbers.</p>
<h3>Server Breakdown</h3>
<p>Anyway, the 48 number crunching servers (blade centers) we had were at full load, so we were pumping more than 170 million messages there. Keep in mind that those servers had a really fast backbone so weren&#8217;t held up by IO. Your environment may be different.</p>
<p>Another 30 (regular pizza boxes) were doing our sagas. Saga state was stored in a distributed in-memory &#8220;cache&#8221;, so once again IO wasn&#8217;t an issue for processing those messages. We were at about 70% utilization there, coming to just over 100 million messages an hour.</p>
<p>The last 20 were clustered boxes (fairly expensive) that handled the various nServiceBus distributor and timeout manager processes were at full load since they handled control messages for all the servers as well as dynamically routing the load. However, on those boxes we used much higher performance disks for the messages, since they had to feed everything else, capable of doing, on average, around 5000 messages a second. That adds up to 360 million messages an hour.</p>
<h3>Unnecessary Durability</h3>
<p>Later, we moved a bunch of messages that didn&#8217;t need all that durability and transactionality off the disks, pushing the total throughput over 1 billion messages an hour. That was about 100 million per hour durable, 900 million per hour non-durable. You can guess that we were left with plenty of IO to spare at that point while we weren&#8217;t yet pushing the limit of our memory.</p>
<p>One thing that&#8217;s important to understand is the size of the messages that didn&#8217;t require durability was less than 1MB, with most weighing in under 10KB. Also, since most of those messages were published, less state management was required around them, enabling us to further improve performance.</p>
<h3>Summary</h3>
<p>NServiceBus didn&#8217;t give us all that by itself. It was the result of skilled architects, developers, and operations staff working together for many iterations, deploying, monitoring, re-designing, etc. You need to understand your technology, your hardware, and your specific performance, availability, and fault-tolerance requirements if you want to get anywhere.</p>
<p>There&#8217;s no magic.</p>
<p>I didn&#8217;t see the number or kinds of servers involved in the Neuron case study so this wasn&#8217;t ever really a comparison. Nor or we talking about the same system here. </p>
<p>So, please, don&#8217;t base your decisions on arbitrary numbers. Spend some time setting up a scaled down version of your target architecture with all the relevant technologies and <em>measure</em>. Be aware that you want high performance end to end, not just of the messaging part. At times, it makes sense to actively throw away messages (of the non-durable, published kind) to help a server come online faster especially after a restart.</p>
<p>Thus ends the tale of another &#8220;benchmark&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2008/05/21/nservicebus-performance/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>WCF, Smart Clients, and Deadlocks</title>
		<link>http://www.udidahan.com/2008/04/11/wcf-smart-clients-and-deadlocks/</link>
		<comments>http://www.udidahan.com/2008/04/11/wcf-smart-clients-and-deadlocks/#comments</comments>
		<pubDate>Fri, 11 Apr 2008 09:15:38 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Simplicity]]></category>
		<category><![CDATA[Smart Client]]></category>
		<category><![CDATA[Threading]]></category>
		<category><![CDATA[WCF]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/04/11/wcf-smart-clients-and-deadlocks/</guid>
		<description><![CDATA[There&#8217;s a new article up on MSDN describing how to write Smart Clients using WCF. The author is none other than WCF-Master Lowy and he goes over the multitude of ways you can deadlock yourself.
Here&#8217;s a taste:
UI Thread and Concurrency Management
Whenever you use hosting on the UI thread, deadlocks are possible. For example, the following [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a new article up on MSDN describing how to write Smart Clients using WCF. The author is none other than <a href="http://www.idesign.net/">WCF-Master Lowy</a> and he goes over the multitude of ways you can deadlock yourself.</p>
<p>Here&#8217;s a taste:</p>
<blockquote><h3>UI Thread and Concurrency Management</h3>
<p>Whenever you use hosting on the UI thread, deadlocks are possible. For example, the following setup is guaranteed to result with a deadlock: A Windows Forms application is hosting a service with <b>UseSynchronizationContext</b> set to <b>true</b>, and UI thread affinity is established. The Windows Forms application then calls the service over one of its endpoints. The call to the service blocks the UI thread, while WCF posts a message to the UI thread to invoke the service. That message is never processed, because of the blocking UI thread—hence, the deadlock.
<p>Another possible case for a deadlock occurs when a Windows Forms application is hosting a service with <b>UseSynchronizationContext</b> set to <b>true</b> and UI thread affinity is established. The service receives a call from a remote client. That call is marshaled to the UI thread and is eventually executed on that thread. If the service is allowed to call out to another service, that can result in a deadlock if the callout causality tries somehow to update the UI or call back to the service’s endpoint, because all of the service instances that are associated with any endpoint (regardless of the service-instancing mode) share the same UI thread.
<p>Similarly, you risk a deadlock if the service is configured for reentrancy and it calls back to its client. You risk a deadlock if the callback causality tries to update the UI or enter the service, because that reentrance must be marshaled to the blocked UI thread.</p>
</blockquote>
<p>Actually, I have difficulty believing that Juval would go so far as to suggest that even the forms should be services, but he does:<br />
<blockquote>
<h3>Form as a Service</h3>
<p>The main motivation for hosting a WCF service on the UI thread is if the service must update the UI or the form. The problem is always: How does the service reach out and obtain a reference to the form? While the techniques and ideas that appear thus far in the listings certainly work, <font color="#800000" size="4"><strong><em>it would be simpler yet if the form were the service</em></strong></font> and hosted itself. For this to work, the form (or any window) must be a singleton service. The reason is that singleton is the only instancing mode that enables you to provide WCF with a live instance to host. In addition, you would not want a per-call form that exists only during a client call (which is usually very brief), nor would you want a per-session form that only a single client can establish a session with and update.
<p>When a form is also a service, <font color="#800000" size="4"><strong><em>having that form as a singleton service is the best instancing mode all around</em></strong></font>.</p>
</blockquote>
<p>I think that this article serves as a great treatise leading to only one conclusion &#8211; you&#8217;d have to be crazy to try to do this without some higher level framework, preferably with a different low-level framework too <img src='http://www.udidahan.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  . Sucks Microsoft didn&#8217;t put one out &#8211; nor is there a pending beta, CTP, or even word about some project with a codename handling this. From what I know about <a href="http://www.codeplex.com/prism">Prism</a>, it doesn&#8217;t intend to handle this issue either.
<p>One thing that isn&#8217;t covered in the article is that if you do choose not to tie the client-side service to the UI thread, you open yourself up to race conditions. Reasons you&#8217;d want to handle messages on a different thread center around UI responsiveness. I&#8217;ve written about these things before:
<ul>
<li>
<h4><a href="http://udidahan.weblogs.us/2007/12/06/object-builder-the-place-to-fix-system-wide-threading-bugs/">Object Builder &#8211; the place to fix system-wide threading bugs</a></h4>
</li>
<li>
<h4><a href="http://udidahan.weblogs.us/2007/12/07/eureka-aop-is-the-final-piece-of-the-multi-threaded-smart-client-puzzle/">Eureka! AOP is the final piece of the multi-threaded smart client puzzle</a></h4>
</li>
<li>
<h4><a href="http://udidahan.weblogs.us/2007/12/26/what-makes-smart-clients-safe/">What Makes Smart Clients Safe?</a></h4>
</li>
</ul>
<p>The more I read things like this, the more I feel that I have to get going with my nServiceBus based solution. I&#8217;m fairly swamped as it is, so if anyone is interested in helping get this project off the ground, I&#8217;d be most grateful &#8211; as I think anyone else that had to build a smart client would. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2008/04/11/wcf-smart-clients-and-deadlocks/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>NServiceBus Explanations</title>
		<link>http://www.udidahan.com/2008/03/30/nservicebus-explanations-3/</link>
		<comments>http://www.udidahan.com/2008/03/30/nservicebus-explanations-3/#comments</comments>
		<pubDate>Sun, 30 Mar 2008 11:36:48 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Messaging]]></category>
		<category><![CDATA[NServiceBus]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Ayende&#8217;s been going over nServiceBus, seeing how it&#8217;s built, and raising various questions and concerns. I&#8217;ll begin by taking them from the outside, in &#8211; that is, first API questions, and then internal structure issues.
SendLocal
First of all, the effect of calling SendLocal on IBus takes all the logical messages passed in (params IMessage[] messages), wraps [...]]]></description>
			<content:encoded><![CDATA[<p>Ayende&#8217;s been <a href="http://ayende.com/Blog/archive/2008/03/24/NServiceBus-Review.aspx">going over</a> nServiceBus, seeing how it&#8217;s built, and raising various questions and concerns. I&#8217;ll begin by taking them from the outside, in &#8211; that is, first API questions, and then internal structure issues.</p>
<h3>SendLocal</h3>
<p>First of all, the effect of calling SendLocal on IBus takes all the logical messages passed in (params IMessage[] messages), wraps them in a single TransportMessage, and puts that physical message at the end of the local queue. This call is equivalent to calling &#8220;Send(TransportMessage m, string destination);&#8221; on ITransport when passing in transport.Address as the parameter of destination.</p>
<p>There are numerous advantages to having this method, but one is the most important.</p>
<p>When client send a service a set of messages using &#8220;void Send(params IMessage[] messages);&#8221;, the client is <em>requesting</em> that the server treat this batch of messages as a unit of work. Under certain conditions, the service may choose to ignore the clients wishes &#8211; not least of which because the client has sent a ton of messages and the service doesn&#8217;t want ACID transactions to last a long time as they hurt throughput. In this case the server would use an intercepting message handler to go over those messages and call SendLocal for each. In other words, the server can set up units of work as it sees fit &#8211; taking into account client preference as well.</p>
<p>Other advantages include the ability to break apart complex or long-running logic into an &#8220;internal pipeline&#8221;. The Timeout Manager also makes use of this facility for &#8220;holding onto&#8221; messages until some condition occurs.</p>
<h3>Return(errorCode)</h3>
<p>The reason that integers are used as error codes is just so that you can push enums through them. This is the simplest way to get errors back to the client. More importantly, we take into account who on the client would be interested in this data.</p>
<p>Clients are often built using MVC with an additional Service Agent layer. Service Agents deal with translating the intent of Controllers into messages. Controllers don&#8217;t know about messaging, nor should they. However, they need to know when something fails with calls they initiated. As such, they are the final consumer of these error-code-enums, and integers are used to express them; that way Controllers don&#8217;t need to take a dependency on nServiceBus.</p>
<h3>DoNotContinueDispatchingCurrentMessageToHandlers</h3>
<p>This method on bus is used by intercepting message handlers in order to instruct the bus not to pass the current message on to subsequent handlers in the pipeline. This is often used by authentication and authorization handlers when those checks fail. This is what makes the message handling pipeline possible.</p>
<h3>BuildAndDispatch</h3>
<p>This method is defined on IBuilder and is used by the bus when dispatching messages to handlers. The reason that this exists instead of just having the bus ask the builder to create the handler and dispatch the call itself has to do with client-side threading. You can find the full explanation here &#8211; <a href="http://udidahan.weblogs.us/2007/12/06/object-builder-the-place-to-fix-system-wide-threading-bugs/">Object Builder, the place to fix system-wide threading bugs</a>.</p>
<h3>Summary</h3>
<p>NServiceBus has grown over the years in environments where I&#8217;ve had the luxury of deciding most, if not all of the design of the systems involved. As such, it has taken on just the responsibilities needed from infrastructure in order to develop robust, flexible, and scalable systems. Check out the <a href="http://www.nservicebus.com">nServiceBus site</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2008/03/30/nservicebus-explanations-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I Hate WSDL</title>
		<link>http://www.udidahan.com/2008/03/28/i-hate-wsdl/</link>
		<comments>http://www.udidahan.com/2008/03/28/i-hate-wsdl/#comments</comments>
		<pubDate>Fri, 28 Mar 2008 16:44:28 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[ESB]]></category>
		<category><![CDATA[Messaging]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Pub/Sub]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/03/28/i-hate-wsdl/</guid>
		<description><![CDATA[Ted says it really well, and let me add a big +1.
Note to those who didn&#8217;t attend the session: you didn&#8217;t hear me say it, so I&#8217;ll repeat it: I hate WSDL almost as much as I hate Las Vegas. Ask me why sometime, or if I get enough of a critical mass of questions, [...]]]></description>
			<content:encoded><![CDATA[<p>Ted <a href="http://blogs.tedneward.com/2008/03/28/Hangin+In+Vegas.aspx">says it really well</a>, and let me add a big +1.</p>
<blockquote><p><em>Note to those who didn&#8217;t attend the session: you didn&#8217;t hear me say it, so I&#8217;ll repeat it: I hate WSDL almost as much as I hate Las Vegas. Ask me why sometime, or if I get enough of a critical mass of questions, I&#8217;ll blog it. If you&#8217;ve seen me do talks on Web Services, though, you&#8217;ve probably heard the rant: WSDL creates tightly-coupled endpoints precisely where loose coupling is necessary, WSDL encourages schema definitions that are inflexible and unevolvable, and WSDL intrinsically assumes a synchronous client-server invocation model that doesn&#8217;t really meet the scalability or feature needs of the modern enterprise. And that&#8217;s just for starters.</em>
<p><em>I hate WSDL.</em>
<p><em>I still hate Vegas more, though.</em></p>
</blockquote>
<p><a href="http://udidahan.weblogs.us/wp-content/uploads/image11.png"><img style="border-right: 0px; border-top: 0px; margin: 0px 0px 0px 20px; border-left: 0px; border-bottom: 0px" height="156" alt="image" src="http://udidahan.weblogs.us/wp-content/uploads/image-thumb8.png" width="152" align="right" border="0"></a> Web Services, and WSDL by connection have taken hold of the industry like cancer &#8211; inhibiting the minds of otherwise intelligent developers and architects. Whenever I get the &#8220;Web Services Question&#8221; (Does X support Web Services &#8211; where X is some design pattern, tool, and sometimes nServiceBus), I have to suppress an urge to groan &#8211; I&#8217;ve got the question <em>that</em> many times. The other day I was at a client and Sam, their head architect asked me that question. I gave my stock response:</p>
<blockquote><p>&#8220;When you say &#8216;Web Services&#8217;, are you referring to SOAP or WSDL, and is HTTP a necessary component too?&#8221;</p>
</blockquote>
<p>See how good I got at the suppressing thing?</p>
<p>Sam conceded that Web Services over TCP is OK too, so I pressed on with:</p>
<blockquote><p>&#8220;What about UDP? FTP? MSMQ? Is it still &#8216;Web Services&#8217; then? Is the rule then that &#8216;Web Services&#8217; == SOAP?&#8221;</p>
</blockquote>
<p>At that point, Sam was beginning to get a little flustered. </p>
<blockquote><p>&#8220;And what&#8217;s so great about SOAP? Is it the interoperability? Because that&#8217;s just because it&#8217;s based on XSD.&#8221;</p>
</blockquote>
<p>He didn&#8217;t know how to reply. Instead, he walked away from the whiteboard and sat down. I didn&#8217;t let up:</p>
<blockquote><p>&#8220;And what if we want to do something other than Request/Response? How about one request with many responses? How about many requests and one response? And why does this decision need to be rigid? Shouldn&#8217;t we just be able to decide programmatically how many responses we want to return? Wouldn&#8217;t that flexibility be better than creating huge response structures for web methods to return?&#8221;</p>
</blockquote>
<p><a href="http://udidahan.weblogs.us/wp-content/uploads/image13.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="132" alt="image" src="http://udidahan.weblogs.us/wp-content/uploads/image-thumb9.png" width="189" align="right" border="0"></a> Sam made his last stand:</p>
<blockquote><p>&#8220;Look, we can&#8217;t go and do something different from the rest of the industry. Everybody else is doing Web Services. It&#8217;s not like the technology doesn&#8217;t work.&#8221;</p>
</blockquote>
<p>I gave way, a little:</p>
<blockquote><p>&#8220;If you want, we can offer two interfaces. One, the flexible, robust, scalable XSD over messaging based solution. The second, an icky, synchronous Web Services facade which calls into our first interface. </p>
<p>I&#8217;m not saying that the technology doesn&#8217;t work &#8211; but both of us know that every problem has multiple solutions, some are fragile and error prone like WS, others are more elegant and have decades of knowledge behind them like messaging.</p>
<p>But we can do both if you like. How&#8217;s that?&#8221;</p>
</blockquote>
<p><a href="http://udidahan.weblogs.us/wp-content/uploads/image14.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="166" alt="image" src="http://udidahan.weblogs.us/wp-content/uploads/image-thumb11.png" width="244" align="right" border="0"></a> And it was agreed. The entire system would be built on one-way messaging patterns using XSD in cases where interoperability was required. And WS would be layered on, like a tiny little pig on top of a gigantic lipstick &#8230; thing &#8211; hmm, that metaphor isn&#8217;t really working &#8211; well, you get the idea.</p>
<p>I hate WSDL. Never been to Vegas, though.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2008/03/28/i-hate-wsdl/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SOA Training Videos and Pricing</title>
		<link>http://www.udidahan.com/2008/03/24/soa-training-videos-and-pricing/</link>
		<comments>http://www.udidahan.com/2008/03/24/soa-training-videos-and-pricing/#comments</comments>
		<pubDate>Mon, 24 Mar 2008 10:15:40 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Training]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/03/24/soa-training-videos-and-pricing/</guid>
		<description><![CDATA[It looks like the SOA training videos will start coming in the next week or so. 
So, I&#8217;ve started thinking what else should be included so that you get the most out of them.
Here&#8217;s what I&#8217;ve currently got in mind:

All the powerpoint presentations
Full source and samples of nServiceBus so you can run the code as [...]]]></description>
			<content:encoded><![CDATA[<p>It looks like the <a href="http://udidahan.weblogs.us/2008/02/08/interested-in-soa-training-videos/">SOA training videos</a> will start coming in the next week or so. </p>
<p>So, I&#8217;ve started thinking what else should be included so that you get the most out of them.</p>
<p>Here&#8217;s what I&#8217;ve currently got in mind:</p>
<ul>
<li>All the powerpoint presentations</li>
<li>Full source and samples of nServiceBus so you can run the code as I talk about it</li>
<li>4 hours of <a href="http://udidahan.weblogs.us/2008/02/25/would-you-spend-a-buck-to-save-a-hundred/">online consultation</a> so you can get up to speed quickly in applying these principles and practices to your project</li>
</ul>
<p>If you have anything else in mind that you think will help, please drop me a comment below.</p>
<p>So far, 32 people have expressed interest in getting this and it looks like I should be able to handle up to about 40 in a timely manner with my current setup. I hadn&#8217;t originally thought about corporate licensing, but since there have been some requests (so that all employees can use the information freely, get copies of the DVD&#8217;s, etc), I&#8217;ll be doing that too. If you&#8217;ve already left a comment about your interest in the DVD&#8217;s, I&#8217;ll assume you want the personal option. If you want to change that to the corporate option, please leave a comment either here or on the <a href="http://udidahan.weblogs.us/2008/02/08/interested-in-soa-training-videos/">previous post</a>.</p>
<h3>Pricing</h3>
<p>Ayende mentioned that the guys from Dot Net Rocks are selling Sharepoint training for about $700 per developer for a day of training. I really don&#8217;t know how much to charge for this &#8211; the guys in Australia paid quite a bit and I wouldn&#8217;t want them to feel &#8211; well, like you feel when you find out that the guy sitting next to you on the plane paid half what you did for his ticket; especially given that they&#8217;ve done so much of the production work on the DVD&#8217;s (Simon, Brad &#8211; you guys are my heroes. I really couldn&#8217;t do this without you).</p>
<p>So, I figure that I&#8217;ll hear what <strong>you</strong> guys think that the package is worth first. Leave me comment, or send me an <a href="mailto:DvdPricing@UdiDahan.com">email</a> if you&#8217;d like more anonymity.</p>
<p>I&#8217;d also be interested in hearing what kind of domain you&#8217;re thinking about applying this stuff to &#8211; I might be able to put you in touch with people already applying SOA and nServiceBus in those areas so you can learn from each other as well.</p>
<p>Looking forward to hearing from you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2008/03/24/soa-training-videos-and-pricing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>QCon London 2008 Recap</title>
		<link>http://www.udidahan.com/2008/03/20/qcon-london-2008-recap/</link>
		<comments>http://www.udidahan.com/2008/03/20/qcon-london-2008-recap/#comments</comments>
		<pubDate>Thu, 20 Mar 2008 09:07:06 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[OO]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/03/20/qcon-london-2008-recap/</guid>
		<description><![CDATA[Well QCon was a blast.
NServiceBus Tutorial
I gave a full day tutorial on nServiceBus and we had a full house! The tutorial was about 90% how to think about distributed systems, and 10% mapping those concepts onto nServiceBus. I made an effort to cram about 3 days of a 5 day training course I give clients [...]]]></description>
			<content:encoded><![CDATA[<p>Well QCon was a blast.</p>
<h3>NServiceBus Tutorial</h3>
<p>I gave a full day tutorial on <a href="http://www.nservicebus.com">nServiceBus</a> and we had a full house! The tutorial was about 90% how to think about distributed systems, and 10% mapping those concepts onto nServiceBus. I made an effort to cram about 3 days of a 5 day training course I give clients into one day, but I think I was only about 85% successful. People didn&#8217;t have the time needed to let things really sink in and ask questions, but the <a href="http://tech.groups.yahoo.com/group/nservicebus/">lively forums</a> and <a href="http://udidahan.weblogs.us/2008/02/25/would-you-spend-a-buck-to-save-a-hundred/">skype conversations</a> available will probably do the trick.</p>
<p><a href="http://jim.webber.name/">Jim Webber</a> after looking at the unit testing features of nServiceBus had this to say:</p>
<blockquote><p>&#8220;Oh my God &#8211; you&#8217;ve created testable middleware! It&#8217;ll never catch on. The vendors won&#8217;t have it.&#8221;</p>
</blockquote>
<p>To which I replied that several vendors were already coming on board with their own implementations of transports and saga persistence. I have absolutely no intention, desire, or (quite frankly) the ability to write an enterprise-class middleware runtime. All I hope to do with nServiceBus is to make it so that developers use what&#8217;s out there in one, middleware-product-agnostic way that will make their code more robust and flexible.</p>
<h3>MEST &amp; Mark &#8211; REST &amp; Stefan</h3>
<p>It was also great finally meeting the head MESTian, <a href="http://markclittle.blogspot.com/">Mark Little</a>, who also happens to work for Redhat as SOA Technical Development Manager and Director of Standards in the JBoss division. It was interesting to see the difference between how I went about messaging in nServiceBus (full peer-to-peer including pub/sub) whereas most of the Java world has the messaging infrastructure handled by something database-like in a deployment/networking kind of perspective. If that&#8217;s the way things are done, then I can definitely appreciate the advantages of <a href="http://udidahan.weblogs.us/2007/06/20/space-based-architecture-%e2%80%93-scalable-but-not-much-to-do-with-soa/">Space-Based Architectures</a>.</p>
<p>And I even got to steal <a href="http://www.innoq.com/blog/st/">Stefan Tilkov</a>&#8217;s RESTful ear for an hour or so before I had to jet back home. It looks like we MESTians and RESTians can be one big happy family. I&#8217;m guessing that our despise of WS connects us all at a deeper level <img src='http://www.udidahan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>Core Design Principles</h3>
<p>I also gave a talk about core design principles, &#8220;Intentions &amp; Interfaces &#8211; making patterns concrete&#8221;, and it went over very well especially considering that that was the first time that I gave that talk. You can find the slides <a href="http://www.eos1.dk/qcon-london-2008/slides/UdiDahan_IntentionsAndInterfaces.pdf">here</a>. From the feedback I heard after the talk, I think many people were surprised how many different parts of a system can be designed this way, and how flexible it is without making the code any more complex. The message was this:</p>
<blockquote><p>Make Roles Explicit</p>
</blockquote>
<p>Despite its simplicity, that leads to IEntity, IValidator&lt;T&gt; where T : IEntity, (which I wrote about a year ago &#8211; <a href="http://udidahan.weblogs.us/2007/04/30/generic-validation/">generic validation</a>) and with a bit of Service Locator capabilities, you can add a line of code to your infrastructure that will validate all entities before they&#8217;re sent from the client to the server. </p>
<p>It leads to IFetchingStrategy&lt;T&gt; for improved database loading performance (also a year old &#8211; <a href="http://udidahan.weblogs.us/2007/03/06/better-domain-driven-design-implementation/">better DDD implementation</a> and the <a href="http://udidahan.weblogs.us/2007/09/16/fetching-strategy-nhibernate-implementation-available/">NHibernate implementation</a>). </p>
<p>It&#8217;s also how nServiceBus does message handling &#8211; IMessage, IMessageHandler&lt;T&gt; where T: IMessage, ISaga&lt;T&gt; where T : IMessage.</p>
<h3>San Francisco?</h3>
<p>Just a quick shout to my readers in the San Francisco area, if you&#8217;d be interested in hearing these talks/tutorials, give the organizers of QCon a <a href="mailto:qcon@infoq.com">shout</a> and they&#8217;ll bring me out. That&#8217;s actually what got me to London &#8211; one of the attendees of a talk I gave at Oredev in Sweden last November missed my tutorial there so he put in a request and that did it. (Thanks Jan, I appreciate it!)</p>
<p>If you&#8217;re in a different part of the world and you&#8217;d like to have me give one of these talks, or other ones (I have a fair amount of material on Domain Models/DDD and Occasionally Connected Smart Clients), I&#8217;d be happy to make the trip and see you there as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2008/03/20/qcon-london-2008-recap/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
