<?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; Workflow</title>
	<atom:link href="http://www.udidahan.com/category/workflow/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.udidahan.com</link>
	<description>Enterprise Development Expert &#38; SOA Specialist</description>
	<lastBuildDate>Mon, 08 Mar 2010 14:34:24 +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>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>Prevent technology blow-ups from killing your project</title>
		<link>http://www.udidahan.com/2008/02/27/prevent-technology-blow-ups-from-killing-your-project/</link>
		<comments>http://www.udidahan.com/2008/02/27/prevent-technology-blow-ups-from-killing-your-project/#comments</comments>
		<pubDate>Wed, 27 Feb 2008 09:08:08 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/27/prevent-technology-blow-ups-from-killing-your-project/</guid>
		<description><![CDATA[Why should you put a 10 foot pole between yourself and technology?
Well, because Microsoft (or insert vendor of your choice here &#8211; they&#8217;re all equally guilty of this) tend to deprecate (as in kill) the technology they evangelised just last year/month/week.
Microsoft Sql Server Notification Services are the latest victim.
I hope you don&#8217;t have any application [...]]]></description>
			<content:encoded><![CDATA[<p>Why should you put a 10 foot pole between yourself and technology?</p>
<p>Well, because Microsoft (or insert vendor of your choice here &#8211; they&#8217;re all equally guilty of this) tend to deprecate (as in kill) the technology they evangelised just last year/month/week.</p>
<p>Microsoft Sql Server Notification Services <a href="http://coolthingoftheday.blogspot.com/2008/02/notification-services-in-sql-server.html">are the latest victim</a>.</p>
<p>I hope you don&#8217;t have any application code tied to that technology.</p>
<p>Not that it&#8217;s the only one.</p>
<p>Workflow Foundation&#8217;s warts have started coming out from behind the shiny veneer. It turns out that the threading model is&#8230; <a href="http://www.softwaremaker.net/blog/WindowsWorkflowFoundationMultiThreadedParallelism.aspx">problematic</a> and requires all sorts of workarounds. Hope those are stable. It&#8217;s not like they could have known that we need a high performance way to run our business logic out of the box. I hope you don&#8217;t have to change your application code (sorry, <strike>pictures</strike> diagrams) when you get blocked threads when trying to cancel irrelevant workflows (customer no longer does business with us &#8211; cancel order processing workflows).</p>
<p>I forgot to mention that the solution above is for single-box parallelism &#8211; if you want true scale-out, you need to go back to solution that &#8220;<em>require talented software developer use of call-external-method and handle-external-event activities along with the CLR thread-pool</em>&#8220;. That&#8217;s OK &#8211; I have yet to meet a team/company who attests that they have below average developers.</p>
<p>I apologize for the somewhat sarcastic tone of this post.</p>
<p>It&#8217;s just that I&#8217;m sick of Microsoft handing developers razor-sharp knives, pointy end forward, and after the developer loses a couple of fingers mentions &#8220;oh yah, watch out for these pointy, sharp bits&#8221;.</p>
<p>To the developers out there &#8211; maybe we need kevlar suits before handling these hazardous materials.</p>
<p>To Microsoft &#8211; you think that this doesn&#8217;t alienate your customers?</p>
<p>We&#8217;re all in the same boat together.</p>
<p>I&#8217;m hoping that <a href="http://altdotnet.org/">ALT.NET</a> can help.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2008/02/27/prevent-technology-blow-ups-from-killing-your-project/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>NServiceBus on Virtual TechEd</title>
		<link>http://www.udidahan.com/2008/02/21/nservicebus-on-virtual-teched/</link>
		<comments>http://www.udidahan.com/2008/02/21/nservicebus-on-virtual-teched/#comments</comments>
		<pubDate>Thu, 21 Feb 2008 22:33:58 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/21/nservicebus-on-virtual-teched/</guid>
		<description><![CDATA[Well, I had almost forgot about that interview.
When I was at TechEd Barcelona last November (07), the morning after I flew in I experienced &#8220;the fish bowl&#8221; and Virtual TechEd for the first time. Anyway, after a short chat &#8211; and quite to my surprise, my interviewer, Paul Foster, decided that we should talk about [...]]]></description>
			<content:encoded><![CDATA[<p>Well, I had almost forgot about that interview.</p>
<p>When I was at TechEd Barcelona last November (07), the morning after I flew in I experienced &#8220;the fish bowl&#8221; and <a href="http://www.virtualteched.com">Virtual TechEd</a> for the first time. Anyway, after a short chat &#8211; and quite to my surprise, my interviewer, Paul Foster, decided that we should talk about nServiceBus.</p>
<p>So here it is. The Microsoft/Marketing friendly description of what nServiceBus is and how nicely it plays with things like WCF and WF. Always be a gracious guest. Don&#8217;t bite the hand that feeds you. But a nibble here and there &#8211; well, that you can get away with <img src='http://www.udidahan.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h3>Download:</h3>
<div class="VerboseSpecial">
<p style="font-size: 11px; line-height: 30px"><a style="font-size: 11px; color: #003399; text-decoration: none" href="http://www.virtualteched.com/Videos/EU_1_udahan_pfoster_FB_100.wmv ">Zune</a>&nbsp;<a style="font-size: 11px; color: #003399; text-decoration: none" href="http://www.virtualteched.com/Videos/EU_1_udahan_pfoster_FB_500.mp4"> iPod</a>&nbsp; WMV&nbsp; <a style="font-size: 11px; color: #003399; text-decoration: none" href="http://www.virtualteched.com/Videos/EU_1_udahan_pfoster_FB_100.wmv ">LOW</a> | <a style="font-size: 11px; color: #003399; text-decoration: none" href="http://www.virtualteched.com/Videos/EU_1_udahan_pfoster_FB_300.wmv ">MED</a> | <a style="font-size: 11px; color: #003399; text-decoration: none" href="http://www.virtualteched.com/Videos/EU_1_udahan_pfoster_FB_500.wmv ">HIGH</a><br />They have a Silverlight version available <a href="http://www.virtualteched.com/pages/videos.aspx">here</a> as well &#8211; at the bottom of the page.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2008/02/21/nservicebus-on-virtual-teched/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://www.virtualteched.com/Videos/EU_1_udahan_pfoster_FB_100.wmv" length="9233811" type="video/x-ms-wmv" />
<enclosure url="http://www.virtualteched.com/Videos/EU_1_udahan_pfoster_FB_300.wmv" length="28710717" type="video/x-ms-wmv" />
<enclosure url="http://www.virtualteched.com/Videos/EU_1_udahan_pfoster_FB_500.wmv" length="47015165" type="video/x-ms-wmv" />
		</item>
		<item>
		<title>Sagas and Unit Testing &#8211; Business Process Verification Made Easy</title>
		<link>http://www.udidahan.com/2008/02/04/sagas-and-unit-testing-business-process-verification-made-easy/</link>
		<comments>http://www.udidahan.com/2008/02/04/sagas-and-unit-testing-business-process-verification-made-easy/#comments</comments>
		<pubDate>Mon, 04 Feb 2008 13:09:51 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[Autonomous Services]]></category>
		<category><![CDATA[Business Rules]]></category>
		<category><![CDATA[EDA]]></category>
		<category><![CDATA[ESB]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Pub/Sub]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/02/04/sagas-and-unit-testing-business-process-verification-made-easy/</guid>
		<description><![CDATA[Sagas have always been designed with unit testing in mind. By keeping them disconnected from any communications or persistence technology, it was my belief that it should be fairly easy to use mock objects to test them. I&#8217;ve heard back from projects using nServiceBus this way that they were pleased with their ability to test [...]]]></description>
			<content:encoded><![CDATA[<p>Sagas have always been designed with unit testing in mind. By keeping them disconnected from any communications or persistence technology, it was my belief that it should be fairly easy to use mock objects to test them. I&#8217;ve heard back from projects using nServiceBus this way that they were pleased with their ability to test them, and thought all was well.</p>
<p>Not so.</p>
<p>The other day I sat down to implement and test a non-trivial business process, and the testing was far from easy. Now as developers go, I&#8217;m not great, or an expert on unit testing or TDD, but I&#8217;m above average. It should not have been this hard. And I tried doing it with <a href="http://www.ayende.com/projects/rhino-mocks.aspx">Rhino.Mocks</a>, <a href="http://www.typemock.com/">TypeMock</a>, and finally <a href="http://code.google.com/p/moq/">Moq</a>. It seemed like I was in a no-mans-land, between trying to do state-based testing, and setting expectations on the messages being sent (as well as correct values in those messages), nothing flowed.</p>
<p>Until I finally stopped trying to figure out how to test, and focused on what needed to be tested. I mean, it&#8217;s not like I was trying to build a generic mocking framework like <a href="http://feeds.feedburner.com/~r/DanielCazzulino/~3/228130195/NewMoqfeaturesformockverificationandcreation.aspx">Daniel</a>.</p>
<p>Here&#8217;s an example business process, or actually, part of one, and then we&#8217;ll see how that can be tested. By the way, there will be a post coming soon which describes how we go about analysing a system, coming up with these message types, and how these sagas come into being, so stay tuned. Either that, or just come to <a href="http://qcon.infoq.com/london/presentation/Build+Scalable%2C+Maintainable%2C+Distributed+Enterprise+.NET+Solutions+with+nServiceBus">my tutorial at QCon.</a></p>
<p>On with the process:</p>
<blockquote><p>1. When we receive a CreateOrderMessage, whose “Completed” flag is true, we’ll send 2 AuthorizationRequestMessages to internal systems (for managers to authorize the order), one OrderStatusUpdatedMessage to the caller with a status “Received”, and a TimeoutMessage to the TimeoutManager requesting to be notified – so that the process doesn’t get stuck if one or both messages don’t get a response.</p>
<p>2. When we receive the first AuthorizationResponseMessage, we notify the initiator of the Order by sending them a OrderStatusUpdatedMessage with a status “Authorized1”.</p>
<p>3. When we get “timed out” from the TimeoutManager, we check if at least one AuthorizationResponseMessage has arrived, and if so, publish an OrderAcceptedMessage, and notify the initator (again via the OrderStatusUpdatedMessage) this time with a status of “Accepted”.</p></blockquote>
<p>And here&#8217;s the test:</p>
<div style="overflow: scroll; width: 95%"><!-- code formatted by http://manoli.net/csharpformat/ --><br />
<style type="text/css">            .csharpcode, .csharpcode pre  {  	font-size: small;  	color: black;  	font-family: consolas, "Courier New", courier, monospace;  	background-color: #ffffff;  	/*white-space: pre;*/  }  .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt   {  	background-color: #f4f4f4;  	width: 100%;  	margin: 0em;  } .csharpcode .lnum { color: #606060; }</style>
<pre class="csharpcode">    <span class="kwrd">public</span> <span class="kwrd">class</span> OrderSagaTests
    {
        <span class="kwrd">private</span> OrderSaga orderSaga = <span class="kwrd">null</span>;
        <span class="kwrd">private</span> <span class="kwrd">string</span> timeoutAddress;
        <span class="kwrd">private</span> Saga Saga;     

        [SetUp]
        <span class="kwrd">public</span> <span class="kwrd">void</span> Setup()
        {
            timeoutAddress = <span class="str">"timeout"</span>;
            Saga = Saga.Test(<span class="kwrd">out</span> orderSaga, timeoutAddress);
        }     

        [Test]
        <span class="kwrd">public</span> <span class="kwrd">void</span> OrderProcessingShouldCompleteAfterOneAuthorizationAndOneTimeout()
        {
            Guid externalOrderId = Guid.NewGuid();
            Guid customerId = Guid.NewGuid();
            <span class="kwrd">string</span> clientAddress = <span class="str">"client"</span>;     

            CreateOrderMessage createOrderMsg = <span class="kwrd">new</span> CreateOrderMessage();
            createOrderMsg.OrderId = externalOrderId;
            createOrderMsg.CustomerId = customerId;
            createOrderMsg.Products = <span class="kwrd">new</span> List&lt;Guid&gt;(<span class="kwrd">new</span> Guid[] { Guid.NewGuid() });
            createOrderMsg.Amounts = <span class="kwrd">new</span> List&lt;<span class="kwrd">float</span>&gt;(<span class="kwrd">new</span> <span class="kwrd">float</span>[] { 10.0F });
            createOrderMsg.Completed = <span class="kwrd">true</span>;     

            TimeoutMessage timeoutMessage = <span class="kwrd">null</span>;     

            Saga.WhenReceivesMessageFrom(clientAddress)
                .ExpectSend&lt;AuthorizeOrderRequestMessage&gt;(
                    <span class="kwrd">delegate</span>(AuthorizeOrderRequestMessage m)
                    {
                        <span class="kwrd">return</span> m.SagaId == orderSaga.Id;
                    })
                .ExpectSend&lt;AuthorizeOrderRequestMessage&gt;(
                    <span class="kwrd">delegate</span>(AuthorizeOrderRequestMessage m)
                    {
                        <span class="kwrd">return</span> m.SagaId == orderSaga.Id;
                    })
                .ExpectSendToDestination&lt;OrderStatusUpdatedMessage&gt;(
                    <span class="kwrd">delegate</span>(<span class="kwrd">string</span> destination, OrderStatusUpdatedMessage m)
                    {
                        <span class="kwrd">return</span> m.OrderId == externalOrderId &amp;&amp; destination == clientAddress;
                    })
                .ExpectSendToDestination&lt;TimeoutMessage&gt;(
                    <span class="kwrd">delegate</span>(<span class="kwrd">string</span> destination, TimeoutMessage m)
                    {
                        timeoutMessage = m;
                        <span class="kwrd">return</span> m.SagaId == orderSaga.Id &amp;&amp; destination == timeoutAddress;
                    })
                .When(<span class="kwrd">delegate</span> { orderSaga.Handle(createOrderMsg); });     

            Assert.IsFalse(orderSaga.Completed);     

            AuthorizeOrderResponseMessage response = <span class="kwrd">new</span> AuthorizeOrderResponseMessage();
            response.ManagerId = Guid.NewGuid();
            response.Authorized = <span class="kwrd">true</span>;
            response.SagaId = orderSaga.Id;     

            Saga.ExpectSendToDestination&lt;OrderStatusUpdatedMessage&gt;(
                    <span class="kwrd">delegate</span>(<span class="kwrd">string</span> destination, OrderStatusUpdatedMessage m)
                    {
                        <span class="kwrd">return</span> (destination == clientAddress &amp;&amp;
                                m.OrderId == externalOrderId &amp;&amp;
                                m.Status == OrderStatus.Authorized1);
                    })
                .When(<span class="kwrd">delegate</span> { orderSaga.Handle(response); });     

            Assert.IsFalse(orderSaga.Completed);     

            Saga.ExpectSendToDestination&lt;OrderStatusUpdatedMessage&gt;(
                    <span class="kwrd">delegate</span>(<span class="kwrd">string</span> destination, OrderStatusUpdatedMessage m)
                    {
                        <span class="kwrd">return</span> (destination == clientAddress &amp;&amp;
                                m.OrderId == externalOrderId &amp;&amp;
                                m.Status == OrderStatus.Accepted);
                    })
                .ExpectPublish&lt;OrderAcceptedMessage&gt;(
                    <span class="kwrd">delegate</span>(OrderAcceptedMessage m)
                    {
                        <span class="kwrd">return</span> (m.CustomerId == customerId);
                    })
                .When(<span class="kwrd">delegate</span> { orderSaga.Timeout(timeoutMessage.State); });     

            Assert.IsTrue(orderSaga.Completed);
        }
    }</pre>
</div>
<p>You might notice that this style is a bit similar to the fluent testing found in Rhino Mocks. That&#8217;s not coincidence. It actually makes use of Rhino Mocks internally. The thing that I discovered was that in order to test these sagas, you don&#8217;t need to actually see a mocking framework. All you should have to do is express how messages get sent, and under what criteria those messages are valid.</p>
<p>If you&#8217;re wondering what the OrderSaga looks like, you can find the code right here. It&#8217;s not a complete business process implementation, but its enough to understand how one would look like:</p>
<div style="overflow: scroll; width: 95%"><!-- code formatted by http://manoli.net/csharpformat/ --><br />
<style type="text/css">            .csharpcode, .csharpcode pre  {  	font-size: small;  	color: black;  	font-family: consolas, "Courier New", courier, monospace;  	background-color: #ffffff;  	/*white-space: pre;*/  }  .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt   {  	background-color: #f4f4f4;  	width: 100%;  	margin: 0em;  } .csharpcode .lnum { color: #606060; }</style>
<pre class="csharpcode"><span class="kwrd">using</span> System;
<span class="kwrd">using</span> System.Collections.Generic;
<span class="kwrd">using</span> ExternalOrderMessages;
<span class="kwrd">using</span> NServiceBus.Saga;
<span class="kwrd">using</span> NServiceBus;
<span class="kwrd">using</span> InternalOrderMessages;     

<span class="kwrd">namespace</span> ProcessingLogic
{
    [Serializable]
    <span class="kwrd">public</span> <span class="kwrd">class</span> OrderSaga : ISaga&lt;CreateOrderMessage&gt;,
        ISaga&lt;AuthorizeOrderResponseMessage&gt;,
        ISaga&lt;CancelOrderMessage&gt;
    {
        <span class="preproc">#region</span> config info     

        [NonSerialized]
        <span class="kwrd">private</span> IBus bus;
        <span class="kwrd">public</span> IBus Bus
        {
            set { <span class="kwrd">this</span>.bus = <span class="kwrd">value</span>; }
        }     

        [NonSerialized]
        <span class="kwrd">private</span> Reminder reminder;
        <span class="kwrd">public</span> Reminder Reminder
        {
            set { <span class="kwrd">this</span>.reminder = <span class="kwrd">value</span>; }
        }     

        <span class="preproc">#endregion</span>     

        <span class="kwrd">private</span> Guid id;
        <span class="kwrd">private</span> <span class="kwrd">bool</span> completed;
        <span class="kwrd">public</span> <span class="kwrd">string</span> clientAddress;
        <span class="kwrd">public</span> Guid externalOrderId;
        <span class="kwrd">public</span> <span class="kwrd">int</span> numberOfPendingAuthorizations = 2;
        <span class="kwrd">public</span> List&lt;CreateOrderMessage&gt; orderItems = <span class="kwrd">new</span> List&lt;CreateOrderMessage&gt;();     

        <span class="kwrd">public</span> <span class="kwrd">void</span> Handle(CreateOrderMessage message)
        {
            <span class="kwrd">this</span>.clientAddress = <span class="kwrd">this</span>.bus.SourceOfMessageBeingHandled;
            <span class="kwrd">this</span>.externalOrderId = message.OrderId;     

            <span class="kwrd">this</span>.orderItems.Add(message);     

            <span class="kwrd">if</span> (message.Completed)
            {
                <span class="kwrd">for</span> (<span class="kwrd">int</span> i = 0; i &lt; <span class="kwrd">this</span>.numberOfPendingAuthorizations; i++)
                {
                    AuthorizeOrderRequestMessage req = <span class="kwrd">new</span> AuthorizeOrderRequestMessage();
                    req.SagaId = <span class="kwrd">this</span>.id;
                    req.OrderData = orderItems;     

                    <span class="kwrd">this</span>.bus.Send(req);
                }
            }     

            <span class="kwrd">this</span>.SendUpdate(OrderStatus.Recieved);     

            <span class="kwrd">this</span>.reminder.ExpireIn(message.ProvideBy - DateTime.Now, <span class="kwrd">this</span>, <span class="kwrd">null</span>);
        }     

        <span class="kwrd">public</span> <span class="kwrd">void</span> Timeout(<span class="kwrd">object</span> state)
        {
            <span class="kwrd">if</span> (<span class="kwrd">this</span>.numberOfPendingAuthorizations &lt;= 1)
                <span class="kwrd">this</span>.Complete();
        }     

        <span class="kwrd">public</span> Guid Id
        {
            get { <span class="kwrd">return</span> id; }
            set { id = <span class="kwrd">value</span>; }
        }     

        <span class="kwrd">public</span> <span class="kwrd">bool</span> Completed
        {
            get { <span class="kwrd">return</span> completed; }
        }     

        <span class="kwrd">public</span> <span class="kwrd">void</span> Handle(AuthorizeOrderResponseMessage message)
        {
            <span class="kwrd">if</span> (message.Authorized)
            {
                <span class="kwrd">this</span>.numberOfPendingAuthorizations--;     

                <span class="kwrd">if</span> (<span class="kwrd">this</span>.numberOfPendingAuthorizations == 1)
                    <span class="kwrd">this</span>.SendUpdate(OrderStatus.Authorized1);
                <span class="kwrd">else</span>
                {
                    <span class="kwrd">this</span>.SendUpdate(OrderStatus.Authorized2);
                    <span class="kwrd">this</span>.Complete();
                }
            }
            <span class="kwrd">else</span>
            {
                <span class="kwrd">this</span>.SendUpdate(OrderStatus.Rejected);
                <span class="kwrd">this</span>.Complete();
            }
        }     

        <span class="kwrd">public</span> <span class="kwrd">void</span> Handle(CancelOrderMessage message)
        {     

        }     

        <span class="kwrd">private</span> <span class="kwrd">void</span> SendUpdate(OrderStatus status)
        {
            OrderStatusUpdatedMessage update = <span class="kwrd">new</span> OrderStatusUpdatedMessage();
            update.OrderId = <span class="kwrd">this</span>.externalOrderId;
            update.Status = status;     

            <span class="kwrd">this</span>.bus.Send(<span class="kwrd">this</span>.clientAddress, update);
        }     

        <span class="kwrd">private</span> <span class="kwrd">void</span> Complete()
        {
            <span class="kwrd">this</span>.completed = <span class="kwrd">true</span>;     

            <span class="kwrd">this</span>.SendUpdate(OrderStatus.Accepted);     

            OrderAcceptedMessage accepted = <span class="kwrd">new</span> OrderAcceptedMessage();
            accepted.Products = <span class="kwrd">new</span> List&lt;Guid&gt;(<span class="kwrd">this</span>.orderItems.Count);
            accepted.Amounts = <span class="kwrd">new</span> List&lt;<span class="kwrd">float</span>&gt;(<span class="kwrd">this</span>.orderItems.Count);     

            <span class="kwrd">this</span>.orderItems.ForEach(<span class="kwrd">delegate</span>(CreateOrderMessage m)
                                        {
                                            accepted.Products.AddRange(m.Products);
                                            accepted.Amounts.AddRange(m.Amounts);
                                            accepted.CustomerId = m.CustomerId;
                                        });     

            <span class="kwrd">this</span>.bus.Publish(accepted);
        }
    }
}</pre>
</div>
<p>All this code is online in the subversion repository under /Samples/Saga.</p>
<p>Questions, comments, and general thoughts are always appreciated.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2008/02/04/sagas-and-unit-testing-business-process-verification-made-easy/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>[Presentation files] Asynchronous Systems Architecture for the Web</title>
		<link>http://www.udidahan.com/2008/01/07/presentation-files-asynchronous-systems-architecture-for-the-web/</link>
		<comments>http://www.udidahan.com/2008/01/07/presentation-files-asynchronous-systems-architecture-for-the-web/#comments</comments>
		<pubDate>Mon, 07 Jan 2008 08:17:07 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[ESB]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[Pub/Sub]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2008/01/07/presentation-files-asynchronous-systems-architecture-for-the-web/</guid>
		<description><![CDATA[We had a great turnout yesterday at the Web Developer Community (not user group &#60;grin/&#62;). I passed on the presentation files and code samples to Noam but figured that the rest of my readers might enjoy them as well.
The (pdf) presentation is here:     Asynchronous Systems Architecture for the Web
The code sample [...]]]></description>
			<content:encoded><![CDATA[<p>We had a great turnout <a href="http://udidahan.weblogs.us/2008/01/05/israel-web-user-group-presentation-asynchronous-systems-architecture-for-the-web/">yesterday</a> at the Web Developer Community (not user group &lt;grin/&gt;). I passed on the presentation files and code samples to <a href="http://blogs.microsoft.co.il/blogs/noam">Noam</a> but figured that the rest of my readers might enjoy them as well.</p>
<p>The (pdf) presentation is here:     <a href="http://t5z3gq.bay.livefilestore.com/y1pamfgcLchxsG9jM0gPcmR6pHq2SeIRWJCanNrA0OAwBfhfZSJIikZNUzMg9qDc4iGevgPF7ci7BKSOUpGm9kwbA/AsyncWebLogin.pdf?download">Asynchronous Systems Architecture for the Web</a></p>
<p>The code sample is here:                      <a href="http://t5z3gq.bay.livefilestore.com/y1pamfgcLchxsGWiTjXHwfqlvbhOeecGXRe9nPcjQ98hY6LYTPjZChYNac9-_z27F_YERtNwENl--L-tIYb1ti5XA/UserManagement.zip?download">Asynchronous User Management Code Sample</a></p>
<p>In the sample, you can see the use of sagas to manage the user registration process; store user email and hashed password, send a confirmation &#8220;email&#8221;, when the user clicks the &#8220;link&#8221;, the web server will take the saga id found in the url, and send a message with that id. This will cause the saga to complete and the user to be written to the &#8220;database&#8221;.</p>
<p>Since I didn&#8217;t have an email component on my laptop, and I&#8217;m guessing you don&#8217;t either, the saga just writes the url to the console. Copy and paste it from there into the browser, and you&#8217;re good to go.</p>
<h3>A Word on TimeoutExceptions</h3>
<p>One other thing that I want to call to your attention. When stepping-through the code in the debugger, you&#8217;re liable to spend more time than the Transaction Coordinator likes, which will cause it to rollback and try the message again. This is supposed to happen and occurs by design.</p>
<p>When you&#8217;re actually working with a database in a high performance environment, there will be cases where one transaction locks a page of a table and may cause other transactions to either timeout or be chosen as victims and just tossed. The behavior that best handles this scenario is just to retry the transaction.</p>
<p>However, you don&#8217;t have to write ugly code that checks for the specific error codes of each specific database for your code to work properly. The infrastructure will automatically do that for you &#8211; just let the exception happen. No need to write any try-catch code.</p>
<p>The sample is built on the newly released version of <a href="http://www.nServiceBus.com">nServiceBus</a> (1.6.1) but already contains all the binaries so you don&#8217;t have to set anything up yourself.</p>
<h3>What&#8217;s coming for nServiceBus</h3>
<p>We&#8217;re working towards a 2.0 release in the June-July timeframe which, beyond having the necessary documentation, web site, samples and everything any self-respecting open-source project has, is going to have some amazing grid-style features that will make all the message-priority &amp; dynamic-routing stuff look &#8220;so last year&#8221;. Stay tuned.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2008/01/07/presentation-files-asynchronous-systems-architecture-for-the-web/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>No more workflow for nServiceBus &#8211; please welcome the Saga</title>
		<link>http://www.udidahan.com/2007/12/17/no-more-workflow-for-nservicebus-please-welcome-the-saga/</link>
		<comments>http://www.udidahan.com/2007/12/17/no-more-workflow-for-nservicebus-please-welcome-the-saga/#comments</comments>
		<pubDate>Mon, 17 Dec 2007 11:42:40 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[ESB]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/12/17/no-more-workflow-for-nservicebus-please-welcome-the-saga/</guid>
		<description><![CDATA[As a part of my efforts to make clearer what place nServiceBus has in the Microsoft .NET ecosystem, I&#8217;ve decided to retire the term &#8220;workflow&#8221;.  Almost every conversation about nServiceBus where the term &#8220;workflow&#8221; was brought up, the reaction was almost identical:
&#8220;What&#8217;s wrong with Workflow Foundation? Why aren&#8217;t you using it like you use [...]]]></description>
			<content:encoded><![CDATA[<p>As a part of my efforts to make clearer what place <a href="http://www.nservicebus.com">nServiceBus</a> has in the Microsoft .NET ecosystem, I&#8217;ve decided to retire the term &#8220;workflow&#8221;.  Almost every conversation about nServiceBus where the term &#8220;workflow&#8221; was brought up, the reaction was almost identical:</p>
<p>&#8220;What&#8217;s wrong with Workflow Foundation? Why aren&#8217;t you using it like you use WCF?&#8221;</p>
<p>There&#8217;s nothing wrong with Workflow Foundation. The thing is that nServiceBus doesn&#8217;t really need workflow in the general sense of the term.  An older term that&#8217;s been used in the DBMS community might make more sense &#8211; &#8220;long-lived transactions&#8221;. You see, nServiceBus requires state management over many messaging interactions, and thus, some kind of long-lived transaction to maintain consistency.</p>
<p>In 1987, a different model was introduced for handling these scenarios &#8211; the Saga [<a href="http://www.cs.cornell.edu/andru/cs711/2002fa/reading/sagas.pdf">GARCIA-MOLINA 87</a>], and was further expanded in 1992 [<a href="http://citeseer.ist.psu.edu/chrysanthis92acta.html">CHRYSANTHIS 92</a>] to allow the saga to commit if a non-vital subset of the sub-transactions abort. This is what is used in nServiceBus.</p>
<p>When used in distributed manner on top of one-way messaging, this results in a solution where each service runs its own &#8220;mini-workflow&#8221;, and coordinates its actions with other services via messages. This integration style is different from the traditional broker, man-in-the-middle approach found in products like Biztalk; and is known as &#8220;choreography&#8221;, and is in the process of standardization in the WS-* specs, known as <a href="http://www.w3.org/TR/ws-chor-model/">WS-Choreography</a>.</p>
<p>So, the bottom line is that the source, examples, and documentation of nServiceBus is being moved in this direction. The source and examples on the <a href="http://sourceforge.net/projects/nservicebus">sourceforge site</a> have already been brought forward. This is a breaking change.</p>
<p>I hope that this will make it clearer that nServiceBus is a higher-level set of abstractions than WCF/WF &#8211; limiting the generality found in these frameworks to enable one cohesive way of working that will result in a solution that is both scalable and robust. On the other hand, nServiceBus is not a fully integrated product like Biztalk and intends to tackle different kinds of problems.</p>
<p>Bigger than a WCF/WF, smaller than a <strike>breadbox</strike> Biztalk.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/12/17/no-more-workflow-for-nservicebus-please-welcome-the-saga/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>In-Order Messaging a Myth?</title>
		<link>http://www.udidahan.com/2007/12/09/in-order-messaging-a-myth/</link>
		<comments>http://www.udidahan.com/2007/12/09/in-order-messaging-a-myth/#comments</comments>
		<pubDate>Sun, 09 Dec 2007 06:00:04 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[EDA]]></category>
		<category><![CDATA[ESB]]></category>
		<category><![CDATA[MSMQ]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Pub/Sub]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/12/09/in-order-messaging-a-myth/</guid>
		<description><![CDATA[I got this question the other day from one of my long-time readers Bill about nServiceBus and I thought I&#8217;d share:
I have a question around processing of messages in proper order.&#160; When leveraging multiple threads to process messages in a message queue, it is possible for the second message in the queue to get processed [...]]]></description>
			<content:encoded><![CDATA[<p>I got this question the other day from one of my long-time readers Bill about <a href="http://www.nServiceBus.com">nServiceBus</a> and I thought I&#8217;d share:</p>
<blockquote><p>I have a question around processing of messages in proper order.&#160; When leveraging multiple threads to process messages in a message queue, it is possible for the second message in the queue to get processed before the first &#8211; especially if the first message is considerably larger than the second.&#160; I have taken a lot of care to make sure that messages are sent in the correct order, only to find that the receiving system can process them out of order anyway.</p>
<p>Consider a Policy Created notification, which must come before a Policy Approved notification.&#160; If both messages are sitting in the queue when the receiving service starts up, the approval message can be processed before the creation message. How can I make sure that message ordering is respected by the receiving system?&#160; I am using <a href="http://udidahan.weblogs.us/category/wcf">WCF</a>/<a href="http://udidahan.weblogs.us/category/msmq">MSMQ</a> as the underlying transport by the way.&#160; The only way I have found so far is to limit the receiving service to a single thread, which is by no means desirable.</p>
</blockquote>
<p>Well, the solution is really quite simple (at first). </p>
<p>If you&#8217;ve received a message that you think has arrived out of order, just call:</p>
<p><font face="Consolas" size="4">this.bus.HandleCurrentMessageLater();</font></p>
<p>and that will put the message back at the end of the queue. </p>
<p>Once you start considering the fact that you don&#8217;t know when the first message is supposed to arrive, you might turn to using a <a href="http://udidahan.weblogs.us/category/workflow">workflow</a> to handle the logic. The workflow would store the policy id, and then allow for N round-trips, before it decided that something bad had happened (like the Policy Created message getting lost), and then it could forward that to an operator, or possibly contact the first system and ask for a replay of the policy created message &#8211; or whatever automated fault resolution protocol you like.</p>
<p>In other words, message ordering is probably more trouble than its worth.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/12/09/in-order-messaging-a-myth/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Asynchronous, High-Performance Login for Web Farms</title>
		<link>http://www.udidahan.com/2007/11/10/asynchronous-high-performance-login-for-web-farms/</link>
		<comments>http://www.udidahan.com/2007/11/10/asynchronous-high-performance-login-for-web-farms/#comments</comments>
		<pubDate>Sat, 10 Nov 2007 16:08:46 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Autonomous Services]]></category>
		<category><![CDATA[Availability]]></category>
		<category><![CDATA[Caching]]></category>
		<category><![CDATA[Data Access]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[ESB]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Pub/Sub]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Scalability]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/11/10/asynchronous-high-performance-login-for-web-farms/</guid>
		<description><![CDATA[Often during my consulting engagements I run into people who say, &#34;some things just can&#8217;t be made asynchronous&#34; even after they agree about the inherent scalability that asynchronous communications pattern bring. One often-cited example is user authentication &#8211; taking a username and password combo and authenticating it against some back-end store. For the purpose of [...]]]></description>
			<content:encoded><![CDATA[<p>Often during my consulting engagements I run into people who say, &quot;some things just can&#8217;t be made asynchronous&quot; even after they agree about the inherent scalability that asynchronous communications pattern bring. One often-cited example is user authentication &#8211; taking a username and password combo and authenticating it against some back-end store. For the purpose of this post, I&#8217;m going to assume a database. Also, I&#8217;m not going to be showing more advanced features like ETags to further improve the solution.</p>
<h3>The Setup</h3>
<p>Just so that the example is in itself secure, we&#8217;ll assume that the password is one-way hashed before being stored. Also, given a reasonable network infrastructure our web servers will be isolated in the <a href="http://en.wikipedia.org/wiki/Demilitarized_zone_(computing)">DMZ</a> and will have to access some application server which, in turn, will communicate with the DB. There&#8217;s also a good chance for something like round-robin load-balancing between web servers, especially for things like user login.</p>
<p>Before diving into the meat of it, I wanted to preface with a few words. One of the commonalities I&#8217;ve found when people dismiss asynchrony is that they don&#8217;t consider a real deployment environment, or scaling up a solution to multiple servers, farms, or datacenters.</p>
<h3>The Synchronous Solution</h3>
<p>In the synchronous solution, each one of our web servers will be contacting the app server for each user login request. In other words, the load on the app server and, consequently, on the database server will be proportional to the number of logins. One property of this load is its data locality, or rather, the lack of it. Given that user U logged in, the DB won&#8217;t necessarily gain any performance benefits by loading all username/password data into memory for the same page as user U. Another property is that this data is very non-volatile &#8211; it doesn&#8217;t change that often.</p>
<p>I won&#8217;t go to far into the synchronous solution since its been <a href="http://www.michaelnygard.com/blog/2007/11/two_ways_to_boost_your_flaggin.html">analysed</a> numerous times before. The bottom line is that the database is the bottleneck. You could use sharding solutions. Many of the large sites have numerous read-only databases for this kind of data, with one master for updates &#8211; replicating out to the read-only replicas. That&#8217;s <a href="http://www.michaelnygard.com/blog/2007/11/two_quick_observations.html">great</a> if you&#8217;re using a nice cheap database like mySql (of LAMP), not so nice if you&#8217;re running Oracle or MS Sql Server.</p>
<p>Regardless of what you&#8217;re doing in your data tier, you&#8217;re there. Wouldn&#8217;t it be nice to close the loop in the web servers? Even if you are using Apache, that&#8217;s going to be less iron, electricity, and cooling all around. That&#8217;s what the asynchronous solution is all about &#8211; capitalizing on the low cost of memory to save on other things.</p>
<h3>The Asynchronous Solution</h3>
<p>In the asynchronous solution, we cache username/hashed-password pairs in memory on our web servers, and authenticate against that. Let&#8217;s analyse how much memory that takes:</p>
<p>Usernames are usually 12 characters or less, but let&#8217;s take an average of 32 to be sure. Using Unicode we get to 64 bytes for the username. Hashed passwords can run between 256 and 512 <em>bits</em> depending on the algorithm, divide by 8 and you have 64 bytes. That&#8217;s about 128 bytes altogether. So we can safely cache 8 million of these with 1GB of memory per web server. If you&#8217;ve got a million users, first of all, good for you <img src='http://www.udidahan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Second, that&#8217;s just 128 MB of memory &#8211; relatively nothing even for a cheap 2GB web server. </p>
<p>Also, consider the fact that when registering a new user we can check if such a username is already taken at the web server level. That doesn&#8217;t mean it won&#8217;t be checked again in the DB to account for <a href="http://udidahan.weblogs.us/2007/01/22/realistic-concurrency/">concurrency issues</a>, but that the load on the DB is further reduced. Other things to notice include no read-only replicas and no replication. Simple. Our web servers are the &quot;replicas&quot;.</p>
<h3>The Authentication Service</h3>
<p>What makes it all work is the &quot;Authentication Service&quot; on the app server. This was always there in the synchronous solution. It is what used to field all the login requests from the web servers, and, of course, allowed them to register new users and all the regular stuff. The difference is that now it publishes a message when a new user is registered (or rather, is validated &#8211; all a part of the internal long-running workflow). It also allows subscribers to receive the list of all username/hashed-password pairs. It&#8217;s also quite likely that it would keep the same data in memory too.</p>
<p>The same message can be used to publish both single updates, and returning the full list when using <a href="http://www.NServiceBus.com">NServiceBus</a>. Let&#8217;s define the message:</p>
<div style="border-right: black 1px solid; padding-right: 1em; border-top: black 1px solid; padding-left: 1em; padding-bottom: 0em; overflow: auto; border-left: black 1px solid; padding-top: 0em; border-bottom: black 1px solid; font-family: courier; background-color: beige">
<p>[Serializable]      <br />public class UsernameInUseMessage : IMessage       <br />{       <br />&#160;&#160;&#160; private string username;       <br />&#160;&#160;&#160; public string Username       <br />&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; get { return username; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; set { username = value; }       <br />&#160;&#160;&#160; } </p>
</p>
<p>&#160;&#160;&#160; private byte[] hashedPassword;      <br />&#160;&#160;&#160; public byte[] HashedPassword       <br />&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; get { return hashedPassword; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; set { hashedPassword = value; }       <br />&#160;&#160;&#160; }       <br />} </p>
</p></div>
<p>And the message that the web server sends when it wants the full list:</p>
</p>
<div style="border-right: black 1px solid; padding-right: 1em; border-top: black 1px solid; padding-left: 1em; padding-bottom: 0em; overflow: auto; border-left: black 1px solid; padding-top: 0em; border-bottom: black 1px solid; font-family: courier; background-color: beige">
<p>[Serializable]      <br />public class GetAllUsernamesMessage : IMessage       <br />{ </p>
<p>} </p>
</p></div>
<p>And the code that the web server runs on startup looks like this (assuming constructor injection):</p>
<p>&#160;</p>
</p>
<div style="border-right: black 1px solid; padding-right: 1em; border-top: black 1px solid; padding-left: 1em; padding-bottom: 0em; overflow: auto; border-left: black 1px solid; padding-top: 0em; border-bottom: black 1px solid; font-family: courier; background-color: beige">
<p>public class UserAuthenticationServiceAgent      <br />{&#160; <br />&#160;&#160;&#160; public UserAuthenticationServiceAgent(IBus bus)&#160; <br />&#160;&#160;&#160; {&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.bus = bus;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; bus.Subscribe(typeof(UsernameInUseMessage));&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; bus.Send(new GetAllUsernamesMessages());       <br />&#160;&#160;&#160; } </p>
<p> }</p></div>
<p>And the code that runs in the Authentication Service when the GetAllUsernamesMessage is received:</p>
</p>
<p>&#160;</p>
</p>
<div style="border-right: black 1px solid; padding-right: 1em; border-top: black 1px solid; padding-left: 1em; padding-bottom: 0em; overflow: auto; border-left: black 1px solid; padding-top: 0em; border-bottom: black 1px solid; font-family: courier; background-color: beige">
<p>public class GetAllUsernamesMessageHandler : BaseMessageHandler&lt;GetAllUsernamesMessage&gt;      <br />{       <br />&#160;&#160;&#160; public override void Handle(GetAllUsernamesMessage message)       <br />&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.Bus.Reply(Cache.GetAll&lt;UsernameInUseMessage&gt;());       <br />&#160;&#160;&#160; }       <br />}</p>
</p></div>
<p>&#160;</p>
<p>And the class on the web server that handles a UsernameInUseMessage when it arrives:</p>
</p>
<p>&#160;</p>
</p>
<div style="border-right: black 1px solid; padding-right: 1em; border-top: black 1px solid; padding-left: 1em; padding-bottom: 0em; overflow: auto; border-left: black 1px solid; padding-top: 0em; border-bottom: black 1px solid; font-family: courier; background-color: beige">
<p>public class UsernameInUseMessageHandler : BaseMessageHandler&lt;UsernameInUseMessage&gt;      <br />{       <br />&#160;&#160;&#160; public override void Handle(UsernameInUseMessage message)       <br />&#160;&#160;&#160; {&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; WebCache.SaveOrUpdate(message.Username, message.HashedPassword);&#160; <br />&#160;&#160;&#160; }       <br />}</p>
</p></div>
<p>When the app server sends the full list, multiple objects of the type UsernameInUseMessage are sent in one physical message to that web server. However, the bus object that runs on the web server dispatches each of these logical messages one at a time to the message handler above.</p>
<p>So, when it comes time to actually authenticate a user, this the web page (or controller, if you&#8217;re doing MVC) would call:</p>
</p>
<div style="border-right: black 1px solid; padding-right: 1em; border-top: black 1px solid; padding-left: 1em; padding-bottom: 0em; overflow: auto; border-left: black 1px solid; padding-top: 0em; border-bottom: black 1px solid; font-family: courier; background-color: beige">
<p>public class UserAuthenticationServiceAgent      <br />{       <br />&#160;&#160;&#160; public bool Authenticate(string username, string password)       <br />&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; byte[] existingHashedPassword = WebCache[username];       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (existingHashedPassword != null)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return existingHashedPassword == this.Hash(password); </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; return false;      <br />&#160;&#160;&#160; }       <br />}</p>
</p></div>
<p>&#160;</p>
<p>When registering a new user, the web server would of course first check its cache, and then send a RegisterUserMessage that contained the username and the hashed password.</p>
</p>
<div style="border-right: black 1px solid; padding-right: 1em; border-top: black 1px solid; padding-left: 1em; padding-bottom: 0em; overflow: auto; border-left: black 1px solid; padding-top: 0em; border-bottom: black 1px solid; font-family: courier; background-color: beige">
<p>[Serializable]      <br />[StartsWorkflow]       <br />public class RegisterUserMessage : IMessage       <br />{       <br />&#160;&#160;&#160; private string username;       <br />&#160;&#160;&#160; public string Username       <br />&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; get { return username; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; set { username = value; }       <br />&#160;&#160;&#160; } </p>
</p>
<p>&#160;&#160;&#160; private string email;      <br />&#160;&#160;&#160; public string Email       <br />&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; get { return email; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; set { email = value; }       <br />&#160;&#160;&#160; } </p>
</p>
<p>&#160;&#160;&#160; private byte[] hashedPassword;      <br />&#160;&#160;&#160; public byte[] HashedPassword       <br />&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; get { return hashedPassword; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; set { hashedPassword = value; }       <br />&#160;&#160;&#160; }       <br />} </p>
</p></div>
<p>&#160;</p>
<p>When the RegisterUserMessage arrives at the app server, a new long-running workflow is kicked off to handle the process:</p>
</p>
<div style="border-right: black 1px solid; padding-right: 1em; border-top: black 1px solid; padding-left: 1em; padding-bottom: 0em; overflow: auto; border-left: black 1px solid; padding-top: 0em; border-bottom: black 1px solid; font-family: courier; background-color: beige">
<p>public class RegisterUserWorkflow :      <br />&#160;&#160;&#160; BaseWorkflow&lt;RegisterUserMessage&gt;, IMessageHandler&lt;UserValidatedMessage&gt;       <br />{       <br />&#160;&#160;&#160; public void Handle(RegisterUserMessage message)       <br />&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; //send validation request to message.Email containing this.Id (a guid)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; // as a part of the URL       <br />&#160;&#160;&#160; } </p>
<p>&#160;&#160;&#160; /// &lt;summary&gt;      <br />&#160;&#160;&#160; /// When a user clicks the validation link in the email, the web server       <br />&#160;&#160;&#160; /// sends this message (containing the workflow Id)       <br />&#160;&#160;&#160; /// &lt;/summary&gt;       <br />&#160;&#160;&#160; /// &lt;param name=&quot;message&quot;&gt;&lt;/param&gt;       <br />&#160;&#160;&#160; public void Handle(UserValidatedMessage message)       <br />&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; // write user to the DB </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.Bus.Publish(new UsernameInUseMessage(      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; message.Username, message.HashedPassword));       <br />&#160;&#160;&#160; }       <br />}</p>
</p></div>
<p>That UsernameInUseMessage would eventually arrive at all the web servers subscribed.</p>
<h3>Performance/Security Trade-Offs</h3>
<p>When looking deeper into this workflow we realize that it could be implemented as two separate message handlers, and have the email address take the place of the workflow Id. The problem with this alternate, better performing solution has to do with security. By removing the dependence on the workflow Id, we&#8217;ve in essence stated that we&#8217;re willing to receive a UserValidatedMessage without having previously received the RegisterUserMessage. </p>
<p>Since the processing of the UserValidatedMessage is relatively expensive &#8211; writing to the DB and publishing messages to <em>all</em> web servers, a malicious user could perform a denial of service (<a href="http://en.wikipedia.org/wiki/Denial-of-service_attack">DOS</a>) attack without that many messages, thus flying under the radar of many detection systems. Spoofing a guid that would result in a valid workflow instance is much more difficult. Also, since workflow instances would probably be stored in some in-memory, replicated data grid the relative cost of a lookup would be quite small &#8211; small enough to avoid a DOS until a detection system picked it up.</p>
<h3>Improved Bandwidth &amp; Latency</h3>
<p>The bottom line is that you&#8217;re getting much more out of your web tier this way, rather than hammering your data tier and having to scale it out much sooner. Also, notice that there is much less network traffic this way. Not such a big deal for usernames and passwords, but other scenarios built in the same way may need more data. Of course, the time it takes us to log a user in is much shorter as well since we don&#8217;t have to cross back and forth from the web server (in the DMZ) to the app server, to the db server.</p>
<p>The important thing to remember in this solution is doing pub/sub. NServiceBus merely provides a simple API for designing the system around pub/sub. And publishing is where you get the serious scalability. As you get more users, you&#8217;ll obviously need to get more web servers. The thing is that you probably won&#8217;t need more database servers <em>just to handle logins</em>. In this case, you also get <a href="http://www.michaelnygard.com/blog/2007/11/architecting_for_latency.html">lower latency</a> per request since all work needed to be done can be done locally on the server that received the request. </p>
<h3>ETags make it even better</h3>
<p>For the more advanced crowd, I&#8217;ll wrap it up with the <a href="http://en.wikipedia.org/wiki/HTTP_ETag">ETags</a>. Since web servers do go down, and the cache will be cleared, what we can do is to write that cache to disk (probably in a background thread), and &quot;tag&quot; it with something that the server gave us along with the last UsernameInUseMessage we received. That way, when the web server comes back up, it can send that ETag along with its GetAllUsernamesMessage so that the app server will only send the changes that occurred since. This drives down network usage even more at the insignificant cost of some disk space on the web servers.</p>
<h3>And in closing&#8230;</h3>
<p>Even if you don&#8217;t have anything more than a single physical server today, and it acts as your web server and database server, this solution won&#8217;t slow things down. If anything, it&#8217;ll speed it up. Regardless, you&#8217;re much better prepared to scale out than before &#8211; no need to rip and replace your entire architecture just as you get 8 million Facebook users banging down your front door.</p>
<p>So, go check out <a href="http://www.NServiceBus.com">NServiceBus</a> and get the most out of your iron.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/11/10/asynchronous-high-performance-login-for-web-farms/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>[Podcast] Durable Services with WCF, WF, and NServiceBus</title>
		<link>http://www.udidahan.com/2007/10/23/podcast-durable-services-with-wcf-wf-and-nservicebus/</link>
		<comments>http://www.udidahan.com/2007/10/23/podcast-durable-services-with-wcf-wf-and-nservicebus/#comments</comments>
		<pubDate>Tue, 23 Oct 2007 21:17:40 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Ask Udi Podcast]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Scalability]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/10/23/podcast-durable-services-with-wcf-wf-and-nservicebus/</guid>
		<description><![CDATA[In this podcast we&#8217;ll look at the issues around Durable Services, what makes them stateful or stateless, as well as how WCF and WF can be used to implement them. Finally, we&#8217;ll compare solutions based on .NET 3.5 and on NServiceBus&#8211;covering aspects such as transactions and persistent time-outs. 
Suresh asks:

Hi Udi,
I&#8217;ve been reading about the [...]]]></description>
			<content:encoded><![CDATA[<p>In this podcast we&#8217;ll look at the issues around Durable Services, what makes them stateful or stateless, as well as how WCF and WF can be used to implement them. Finally, we&#8217;ll compare solutions based on .NET 3.5 and on NServiceBus&#8211;covering aspects such as transactions and persistent time-outs. </p>
<p>Suresh asks:</p>
<blockquote><p>
Hi Udi,</p>
<p>I&#8217;ve been reading about the coming &#8220;durable services&#8221; that will be available with the next version of WCF. I also have been listening to your podcasts and reading your blog posts about NServiceBus where you talk about long-running workflows. It sounds like both of these technologies are trying to solve the same problem.</p>
<p>Do durable services do away with long-running workflow? If so, does that mean we don&#8217;t need Workflow Foundation either? If not, what is the connection between them.</p>
<p>If you could shed some light on the matter that would be great.</p>
<p>Suresh
</p></blockquote>
<p><b>Download</b></p>
<p><a href="http://www.ddj.com/architect/202600413">Download via the Dr. Dobb&#8217;s site</a></p>
<p>Or download directly <a href="http://www.dobbsprojects.com/media/newengine/dynamp.php/071022ud01.mp3?podcast=071022ud01.mp3">here</a></p>
<p><b>Additional References</b></p>
<ul>
<li>Blog post on <A href="http://www.winterdom.com/weblog/2007/06/28/WorkflowServicesInOrcas.aspx">Workflow Services in Orcas</A></li>
<li>Blog post on <A href="http://weblogs.asp.net/gsusx/archive/2007/06/14/orcas-durable-services.aspx">Orcas Durable Services</A></li>
<li>Blog post on <a href="https://www.gazitt.com/blog/PermaLink,guid,a8383226-a0dd-48c5-9fea-33d5da159d17.aspx">.NET Framework 3.5 Beta1 is Live on the Web</a></li>
</ul>
<p><b>Want more?</b></p>
<p>Check out the <a href="/ask-udi/">&#8220;Ask Udi&#8221; archives</a>.</p>
<p><b>Got a question?</b></p>
<p><a href="mailto:podcast@UdiDahan.com">Send Udi your question to answer on the show.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/10/23/podcast-durable-services-with-wcf-wf-and-nservicebus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://www.dobbsprojects.com/media/newengine/dynamp.php/071022ud01.mp3?podcast=071022ud01.mp3" length="16231213" type="audio/mp3" />
		</item>
		<item>
		<title>Generic WCF Transport available for NServiceBus</title>
		<link>http://www.udidahan.com/2007/08/30/generic-wcf-transport-available-for-nservicebus/</link>
		<comments>http://www.udidahan.com/2007/08/30/generic-wcf-transport-available-for-nservicebus/#comments</comments>
		<pubDate>Thu, 30 Aug 2007 23:26:25 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[ESB]]></category>
		<category><![CDATA[MSMQ]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Pub/Sub]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/08/30/generic-wcf-transport-available-for-nservicebus/</guid>
		<description><![CDATA[After trying a bunch of different directions it appears like I&#8217;ve found one that works. I didn&#8217;t think that I could make use of the top ServiceModel stuff, but I was wrong. Many thanks to Tomas Restrepo for making me rethink my basic assumptions.
I&#8217;ve also put in a bit of effort in setting up a [...]]]></description>
			<content:encoded><![CDATA[<p>After trying a bunch of different directions it appears like I&#8217;ve found one that works. I didn&#8217;t think that I could make use of the top ServiceModel stuff, but I was wrong. Many thanks to <a href="http://www.winterdom.com/weblog/">Tomas Restrepo</a> for making me rethink my basic assumptions.</p>
<p>I&#8217;ve also put in a bit of effort in setting up a bunch of configuration files allowing you to try the various transports for the example code. Please go through the Readme as it contains the detailed instructions. There are currently config files setting up non-WCF MSMQ, NetTCP, Basic HTTP, and WS Dual.</p>
<p>If you do go the MSMQ route, the example will run the long-running workflow code. The reason the example code won&#8217;t do that for the WCF cases is that I haven&#8217;t figured out yet the best way for a service to send a message back to itself, especially for the connected bindings. Any thoughts on this would be most appreciated.</p>
<p>Also, I&#8217;m open to hearing what directions you think the next version should go in. I&#8217;m currently thinking about including message transformation. Either that are doing a Multicast bus over a UDP transport.</p>
<p>This is a non-backwards-compatible update. In order to propertly integrate with the WCF philosophy I had to change the ITransport interface for Unicast transports. The meaning of this change is that transports are now expected to do their own threading and transaction management, while the bus object now joins the context that comes from the transport.</p>
<p><a href='http://udidahan.weblogs.us/wp-content/uploads/nservicebus-v10.zip'>Download here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/08/30/generic-wcf-transport-available-for-nservicebus/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>NServiceBus Distributed Topology Q&amp;A</title>
		<link>http://www.udidahan.com/2007/08/25/nservicebus-distributed-topology-qa/</link>
		<comments>http://www.udidahan.com/2007/08/25/nservicebus-distributed-topology-qa/#comments</comments>
		<pubDate>Sat, 25 Aug 2007 08:37:26 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[BizTalk]]></category>
		<category><![CDATA[Dependency Injection]]></category>
		<category><![CDATA[ESB]]></category>
		<category><![CDATA[MSMQ]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Pub/Sub]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/08/25/nservicebus-distributed-topology-qa/</guid>
		<description><![CDATA[I&#8217;ve been receiving more and more questions about how NServiceBus fits in distributed systems and wanted to share them:

My question is about distributed topology.
The EAI-hub-and-spoke model is all about the central server.   It’s useful sometimes, but there are a lot of reasons why I’m not gung-ho on using a hub as the center [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been receiving more and more questions about how NServiceBus fits in distributed systems and wanted to share them:</p>
<blockquote><p>
My question is about distributed topology.</p>
<p>The EAI-hub-and-spoke model is all about the central server.   It’s useful sometimes, but there are a lot of reasons why I’m not gung-ho on using a hub as the center of the integration universe.  </p>
<p>The ESB distributed model puts code on the endpoints.  That code solves some of the messaging problems that apps face, so that apps don’t have to face them. It also solves some of the messaging problems that enterprises face, so that enterprises don’t have to face them.  (I need both).</p>
<p>Those problems include simple coding and deployment model, pub-sub routing, reliable transport, simple transformation, and orchestration.  I wonder which of these you can do in your tool, and which you are planning to do.  </p>
<p>I’m also interested in management.  How do you insure that the endpoints are correctly configured?  Do you have a central configuration store?  How do you propagate changes from the center to the messaging endpoints?
</p></blockquote>
<p>And here&#8217;s my response:</p>
<p>The important parts of NServiceBus that are independent of the distributed topology are the API and the connection to long-running workflow. This code is indeed on the endpoint. However, if you wanted to you could easily connect to something like BizTalk and do whatever you wanted there. This general idea though is to support the ESB distributed model since <a href="udidahan.weblogs.us/2007/06/30/no-such-thing-as-a-centralized-esb/">there&#8217;s no such things as a centralized ESB</a>.</p>
<p>In terms of the capabilities you’ve mentioned, I’ve seen developers pick up the coding model in a day or two. The deployment model is just a bunch of DLLs you deploy with each endpoint. Dependency Injection is supported by www.SpringFramework.net but you can replace that with something else easily as another implementation of the ObjectBuilder interfaces. </p>
<p>Currently pub/sub routing is supported over regular point-to-point transports in a transport agnostic way. You also have the ability to have subscriptions be persisted so that even if a server restarts (and clients don’t, and can’t know about that) all the subscriptions will be remembered. </p>
<p>The reliable transport that is currently supported is MSMQ, with the option of defining per-message type if you want durable messaging (using the [Recoverable] attribute). </p>
<p>In terms of orchestration you get a nice model for long-running workflow that gets kicked off by messages decorated with the [StartsWorkflow] attribute, and messages that implement the IWorkflowMessage interface get automatically routed to the persistent workflow instance. You have the ability to change the storage of workflow instances easily as well. Workflows are simple classes which are easily unit-testable in that they expose a “void Handle(T message);” method for every message type (T) that is involved in the workflow.</p>
<p>I haven’t done anything in terms of simple transformation yet but am currently looking for the right place in the message processing pipeline to put it. I also haven’t done anything yet in terms of management. </p>
<p>What is currently being done management-wise on the projects that use it are the commercial options for managing configuration files in distributed environments coupled with the regular ability to restart windows services and IIS applications. I haven’t seen anything lacking in that solution yet.</p>
<hr size="1" />
<p>If you have any questions, please don&#8217;t hesitate to send them my way &#8211; <a href="mailto:NServiceBus@UdiDahan.com">NServiceBus@UdiDahan.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/08/25/nservicebus-distributed-topology-qa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why I wrote NServiceBus</title>
		<link>http://www.udidahan.com/2007/08/25/why-i-wrote-nservicebus/</link>
		<comments>http://www.udidahan.com/2007/08/25/why-i-wrote-nservicebus/#comments</comments>
		<pubDate>Sat, 25 Aug 2007 08:28:28 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[ESB]]></category>
		<category><![CDATA[MSMQ]]></category>
		<category><![CDATA[NServiceBus]]></category>
		<category><![CDATA[Pub/Sub]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/08/25/why-i-wrote-nservicebus/</guid>
		<description><![CDATA[I&#8217;ve been asked if I have a document describing the architecture of NServiceBus, so since I don&#8217;t have one yet, this post will be the start.
First of all, there were two major forces that drove me to write NServiceBus. First of all I wanted to formalize the way Service Layer classes were written when using [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been asked if I have a document describing the architecture of NServiceBus, so since I don&#8217;t have one yet, this post will be the start.</p>
<p>First of all, there were two major forces that drove me to write NServiceBus. First of all I wanted to formalize the way Service Layer classes were written when using asynchronous messaging (regardless of Web Services). And second I wanted to formalize a communications API which supported pub/sub so that I could freely move between transports – whether they inherently supported pub/sub or not (the fact that Indigo did not falls under this).</p>
<p>From there it was filling in the details. Until finally I made the step to formalize the way long-running workflow connects to asynchronous messaging. That’s the third pillar as far as I’m concerned about ESBs. Using MSMQ I do enable Shared Subscriptions like Sonic does.</p>
<p>I try to stay away from the vendor side of ESB definitions and just deal with what capabilities such a library should provide. As such, it is inherently distributed – running on each server/client.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/08/25/why-i-wrote-nservicebus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t EDA between existing systems</title>
		<link>http://www.udidahan.com/2007/08/16/dont-eda-between-existing-systems/</link>
		<comments>http://www.udidahan.com/2007/08/16/dont-eda-between-existing-systems/#comments</comments>
		<pubDate>Thu, 16 Aug 2007 12:54:21 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Autonomous Services]]></category>
		<category><![CDATA[BPM]]></category>
		<category><![CDATA[EDA]]></category>
		<category><![CDATA[ESB]]></category>
		<category><![CDATA[Pub/Sub]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Simplicity]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/08/16/dont-eda-between-existing-systems/</guid>
		<description><![CDATA[In Nick Malik&#8217;s great post, EDA: Avoiding coupling on the name he describes additional &#8220;handshakes&#8221; to be used to avoid the following problems:

Let&#8217;s say I have a system to handle a call center for financial services or telco.  When a customer calls on the phone and asks to be enrolled in &#8220;Heavily Advertised Program [...]]]></description>
			<content:encoded><![CDATA[<p>In Nick Malik&#8217;s great post, <a href="http://blogs.msdn.com/nickmalik/archive/2007/08/12/eda-avoiding-coupling-on-the-name.aspx">EDA: Avoiding coupling on the name</a> he describes additional &#8220;handshakes&#8221; to be used to avoid the following problems:</p>
<blockquote><p>
Let&#8217;s say I have a system to handle a call center for financial services or telco.  When a customer calls on the phone and asks to be enrolled in &#8220;Heavily Advertised Program ABC,&#8221; there may need to be three or four systems that interact to make that real.</p>
<p>&#8230;</p>
<p>Harry asks me to consider using a &#8216;logical name&#8217; of the receiver.  The sender contacts a logical end point, the addressing infrastructure turns that into a physical end point, and we still have decoupling.  </p>
<p>Honestly, I like it but I think it is insufficient.  What if we need to contact 20 downstream systems in a complex workflow, but I don&#8217;t want a single &#8220;orchestration coordinator&#8221; to be a bottleneck (or single point of failure).  I don&#8217;t want to hand the orchestration off from my app to a central orchestration hub.
</p></blockquote>
<p>Let me propose a different approach.</p>
<p>When we use SOA/EDA (the same thing as far as I&#8217;m concerned), the top-level building block used is the Service. A service may make use of a number of existing systems to perform its work. The business-level events that we publish (and subscribe to) are done by the service, not the existing systems.</p>
<p>If there&#8217;s any orchestration/workflow that needs to be done as a result of a service receiving an event, it is done entirely internal to that service. Inter-service orchestrations don&#8217;t really exist, as in there is no orchestration coordinator that is not in a service. And the orchestration coordinators within a service don&#8217;t touch other services&#8217; back-end systems &#8211; if anything, they publish other business level events.</p>
<p>Be aware: when just starting out on an SOA, you&#8217;ll find that multiple Services make use of the same backend systems. This may be necessary, but not a desirable state to stay in for too long since it embodies the most insidious and invisible kind of inter-service coupling there is.</p>
<p>I want to go back to Nick&#8217;s original question:</p>
<blockquote><p>So what if no one picks the message up?  Is that an error? </p></blockquote>
<p>The answer is mu.</p>
<p>If a service publishes a business-event (message) and no other services currently care, that&#8217;s fine. It&#8217;s not an error. Actually, you&#8217;d probably have some kind of infrastructure &#8220;queue&#8221; where messages that haven&#8217;t been received more than X time get sent to, so that the event isn&#8217;t &#8220;lost&#8221;. On the other hand, within a service &#8211; if an existing system sends out a message that <i>needs</i> to arrive at another system, and that message doesn&#8217;t arrive or isn&#8217;t picked up &#8220;in time&#8221;, that is an error.</p>
<p>This is one of the advantages SOA brings to the table in terms of EDA (again, the same as far as I&#8217;m concerned). You get simple messaging semantics between services, while within the &#8220;sphere of control&#8221; of a service you need, and more importantly can do more complex messaging and orchestration.</p>
<p>Bottom line: you need higher abstractions than your existing systems to employ EDA effectively.</p>
<p>You might also want to check out my podcast on this topic: <a href="http://udidahan.weblogs.us/2006/06/13/podcast-soa-esb-and-events-no-20/">SOA, ESB, and Events</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/08/16/dont-eda-between-existing-systems/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>NBus now supporting long running workflow</title>
		<link>http://www.udidahan.com/2007/07/12/nbus-now-supporting-long-running-workflow/</link>
		<comments>http://www.udidahan.com/2007/07/12/nbus-now-supporting-long-running-workflow/#comments</comments>
		<pubDate>Thu, 12 Jul 2007 23:05:10 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[ESB]]></category>
		<category><![CDATA[MSMQ]]></category>
		<category><![CDATA[Pub/Sub]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/07/12/nbus-now-supporting-long-running-workflow/</guid>
		<description><![CDATA[This is a backwards-compatible update to the last drop of my messaging infrastructure &#8211; NBus. For more information on what it&#8217;s about read what such an infrastructure should do.
This update includes support for long-running workflows and includes persistent timer functionality. Workflow persistence is abstracted behind an IWorkflowPersister. The current drop includes an in-memory persister, but [...]]]></description>
			<content:encoded><![CDATA[<p>This is a backwards-compatible update to <a href="http://udidahan.weblogs.us/2007/07/07/download-vnext-of-the-messaging-infrastructure/">the last drop of my messaging infrastructure &#8211; NBus</a>. For more information on what it&#8217;s about read <a href="http://udidahan.weblogs.us/2007/04/22/basic-messaging-infrastructure/">what such an infrastructure should do</a>.</p>
<p>This update includes support for long-running workflows and includes persistent timer functionality. Workflow persistence is abstracted behind an IWorkflowPersister. The current drop includes an in-memory persister, but you could easily implement it over a database, or a <a href="http://udidahan.weblogs.us/2007/05/05/using-spaces-with-web-services/">distributed in-memory datagrid / space</a>.</p>
<p>Other important details. To have a message kick off a workflow, just put the StartsWorkflow attribute on it. To define a message type as being involved in workflows, have it implement IWorkflowMessage instead of just IMessage. If you do these two things, the infrastructure will be able to generically dispatch messages to your workflow; you will not have to write any message handlers for your workflow, just the workflow class itself. This is done by implementing IWorkflow&lt;T&gt; for every message type received.</p>
<p>Persistent timers are activated from within your workflow like so:</p>
<p>this.reminder.ExpireIn(TimeSpan.FromSeconds(5), this, state);</p>
<p>As always, dependency injection is used &#8211; via my simple ObjectBuilder. The implementation provided delegates to Spring, but, once again, that can be easily substituted with whatever you want.</p>
<p><a href="http://udidahan.weblogs.us/wp-content/uploads/nbus_with_workflow.zip" title="nbus_with_workflow.zip">Download (509 KB)</a> (sometimes problematic with IE, try FireFox before emailing me).</p>
<p>Finally, I&#8217;m leaning towards changing the name to NServiceBus. Anyone against, please leave a comment. Questions and comments are more than welcome.</p>
<p>Next step: implementing a WCF transport.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/07/12/nbus-now-supporting-long-running-workflow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Space-Based Architecture – scalable, but not much to do with SOA</title>
		<link>http://www.udidahan.com/2007/06/20/space-based-architecture-%e2%80%93-scalable-but-not-much-to-do-with-soa/</link>
		<comments>http://www.udidahan.com/2007/06/20/space-based-architecture-%e2%80%93-scalable-but-not-much-to-do-with-soa/#comments</comments>
		<pubDate>Wed, 20 Jun 2007 21:31:25 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Autonomous Services]]></category>
		<category><![CDATA[Availability]]></category>
		<category><![CDATA[EDA]]></category>
		<category><![CDATA[ESB]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Pub/Sub]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Scalability]]></category>
		<category><![CDATA[Simplicity]]></category>
		<category><![CDATA[Space-Based Architecture]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/06/20/space-based-architecture-%e2%80%93-scalable-but-not-much-to-do-with-soa/</guid>
		<description><![CDATA[Space-Based Architecture (or SBA for short) just might be in your future if your building large-scale distributed systems. By focusing on high-throughput and low latency, SBA joins messaging and in-memory data caching and adds a good measure of load partitioning. However, with the entire industry enamoured with SOA, what place is left for SBA?
Before going [...]]]></description>
			<content:encoded><![CDATA[<p>Space-Based Architecture (or SBA for short) just might be in your future if your building large-scale distributed systems. By focusing on high-throughput and low latency, SBA joins messaging and in-memory data caching and adds a good measure of load partitioning. However, with the entire industry enamoured with SOA, what place is left for SBA?</p>
<p>Before going too far ahead, you might want to take a look at my previous post <a href="http://udidahan.weblogs.us/2007/01/20/space-based-architectural-thinking/">&#8220;Space-Based Architectural Thinking</a>, or listen to my podcast <a href="http://udidahan.weblogs.us/2007/04/10/podcast-space-based-architectures-for-the-web/">Space-Based Architecture for the Web</a>. There&#8217;s also a 30 minute webcast online describing SBA more fully <a href="http://www.bejug.org/confluenceBeJUG/display/PARLEYS/SBA+-+Scalable+SOA">here</a>. I&#8217;m also going to try to stay away from things concerning Jini this time after already discussing <a href="http://udidahan.weblogs.us/2007/06/12/don%e2%80%99t-let-the-jini-out-of-the-bottle-on-soa/">the connection between Jini and SOA</a>, and the tradeoffs between two general approaches: <a href="http://udidahan.weblogs.us/2007/05/10/tasks-and-spaces-versus-messages-and-handlers/">Tasks and Spaces vs Message and Handlers</a>.</p>
<p>OK, so the issue of state-management is a big one. Everybody wants to work stateless, because it scales. The only problem is that the business processes that we are automating are long running, meaning that there are external systems or people involved. This makes these processes inherently stateful. So, we need a way to scale statefully &#8211; SBA gives us that. For some background on the &#8220;Shared Nothing Architecture&#8221;, I suggest reading <a href="http://www.dehora.net/journal/2004/04/interprocess_soa.html">this post on inter-process SOA</a> and <a href="http://www.zefhemel.com/archives/2004/09/01/the-share-nothing-architecture">this one as well</a>.</p>
<p>Availability also has to be handled, not only in terms of having enough servers online to handle the required load but in having all the data required to process each request be accessible. This has often been handled by the database using ACID transactions &#8211; durability being that which solved availability issues, but also hurting latency the most. The problem with saving the state of our long-running business processes/workflows in the database is the load and the responsiveness requirements. In many verticals &#8211; telcos, financial, and defense to name a few, we need millisecond level latency on each stage of the workflow. This is what leads SBA to the in-memory, replicated data grid.</p>
<p>Note that SBA only intends to take these workflows out of the database, and not anything else &#8211; especially not Master Data. The lifetime of these workflows is incredibly short compared to that of master data like customers and products. It will have much different backup strategies as well. In terms of load, these workflows will be heavy on reads and writes together in the same transactions, but quite low in terms of just reads. If we have workflows that perform work in parallel, we easily end up with concurrency requirements that make DBAs cringe under the barrage of short transactions. </p>
<blockquote style="background-color:white"><p>
If you&#8217;re worried that Workflow Foundation (WF) won&#8217;t scale because of the above, you needn&#8217;t be. You can (more or less easily) replace the persistence mechanism of WF with your own, saving your workflow instances to an in-memory replicated data grid.
</p></blockquote>
<p>By enabling the objects in the grid to call back into logic on your servers, you have, in essence, done messaging and more. The added benefit that SBA receives from this is a unification of technology between caching and messaging. This translates directly to savings when it comes time to cluster each of those technology&#8217;s environments.</p>
<p>Finally, if we can find an attribute in the incoming stream of messages that creates a nice even distribution, we can then partition our load between our servers by that key. This will work up to the point where the load per key increases beyond a single server&#8217;s capacity, and then we have to look at re-partitioning, a non-trivial problem. However, if we put objects in our grid that represent the master data, and tie them to our workflow instances with both of those tied to the key of our load, a smart infrastructure can make sure all that data is already resident on the server that is handling that piece of the load. That decreases latency even more since we no longer have to pay network roundtrips to collect all the data needed before we can process it. That&#8217;s a substantial advantage for the above verticals.</p>
<p>But all of this has nothing to do with SOA.</p>
<p>Sure, it&#8217;ll change how we implement our Services internally, but it has no impact on their interfaces or the top-level service decomposition. In the Java community, the word &#8220;service&#8221; is often used to describe the logic of a system. Great significance is placed on keeping these &#8220;services&#8221; simple, as in Plain-Old Java Objects. The fact of the matter is that the logic of the system should be simple and independent of other concerns like data access and communcations (a la Web Services), but that does not make it a service, not in the SOA sense.</p>
<p>For more information on what Services in SOA are like, check out this podcast on <a href="http://udidahan.weblogs.us/2006/08/28/podcast-business-and-autonomous-components-in-soa/">Business and Autonomous Components in SOA</a>. Actually, SBA will probably have the biggest impact on the way <a href="http://udidahan.weblogs.us/2007/06/02/podcast-using-autonomous-components-for-slas-in-soa/">autonomous components will handle service-level agreements</a>.</p>
<p>So, it appears that even with SOA, SBA has its place. The former dealing with business level agility, the latter dealing with all the technical aspects of supporting that agility. If you&#8217;re tasked with the designing the architecture of a scalable, available, high-throughput, low-latency distributed system, I&#8217;d strongly advise you to look at SBA &#8211; the technical value is overwhelming. Even if you don&#8217;t utilize all elements of SBA and choose the <a href="http://www.theserverside.com/tt/articles/article.tss?l=DistCompute">Master Worker Pattern</a> instead of load partitioning, you&#8217;ll find the technologies supporting SBA to be quite flexible in that respect.</p>
<p>Will Space-Based Architectures be a part of your future? I don&#8217;t know for sure, but they&#8217;re a most welcome part of my present.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/06/20/space-based-architecture-%e2%80%93-scalable-but-not-much-to-do-with-soa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Workflow Failures Easier to Solve Than Ever Before</title>
		<link>http://www.udidahan.com/2007/06/08/workflow-failures-easier-to-solve-than-ever-before/</link>
		<comments>http://www.udidahan.com/2007/06/08/workflow-failures-easier-to-solve-than-ever-before/#comments</comments>
		<pubDate>Fri, 08 Jun 2007 08:45:54 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Simplicity]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/06/08/workflow-failures-easier-to-solve-than-ever-before/</guid>
		<description><![CDATA[So you&#8217;re code threw an exception for some reason. Now, your WF workflow gets terminated. You&#8217;re not a happy camper. You go looking for help and find this practical set of solutions, but think to yourself &#8220;it shouldn&#8217;t be this hard&#8221;.
And you&#8217;re absolutely right.
The fact of the matter is, you don&#8217;t have to do anything [...]]]></description>
			<content:encoded><![CDATA[<p>So you&#8217;re code threw an exception for some reason. Now, your WF workflow gets terminated. You&#8217;re not a happy camper. You go looking for help and find <a href="http://blogs.msdn.com/sajay/archive/2007/05/02/musings-on-workflow-termintated-and-exception-handling.aspx">this practical set of solutions</a>, but think to yourself &#8220;it shouldn&#8217;t be <i>this</i> hard&#8221;.</p>
<p>And you&#8217;re absolutely right.</p>
<p>The fact of the matter is, you don&#8217;t have to do anything special to deal with failures in workflow. It all can be handled in terms of messaging, since the only interesting kind of workflow is the &#8220;long-running&#8221; kind. Long running workflows are those that may involve calling out to other services/systems, or involve humans in the process. Conversely, &#8220;short-running&#8221; workflows involve receiving a single message, handling it by calling code on the same server, in the same process, and on the same thread, and possibly returning a response. Simple request/response interaction is short-running. Things you might think to use BizTalk for would probably be long-running.</p>
<p>Take a look at this post which shows that <a href="http://udidahan.weblogs.us/2007/05/12/service-enabled-workflows-with-wf-and-wcf/">long-running workflow is just regular messaging with a sprinkle of state-management</a>.</p>
<p>Anyway, in my article <a href="http://udidahan.weblogs.us/2007/02/15/it%E2%80%99s-poison-i-tell-you-poison/">describing failure handling for messaging</a>, these workflow failures fall under the following category and solution:</p>
<blockquote><p>
Other kinds of failure conditions include having our DB transactions fail because they were chosen as the victim of a deadlock. The appropriate system level error handling is to just retry the transaction a bit later. Once again, if we were using our queues within the context of a transaction scope that included that of the database, the message would return to the queue when that deadlock exception bubbled through. This is exactly the behavior that we want in this case, although having the message go to the end of the queue instead of the front would also be just fine.</p>
<p>Other kinds of failure conditions we might run into include things like unique-constraint violations, attempting to perform actions on entities that no longer exist, and other activities where trying them over again probably won’t yield any different behavior. In these cases, if an exception were to cause the perpetrating message to return to the input queue we’d get exactly the wrong behavior. At the very least we would want to maybe log the exception information
</p></blockquote>
<p>So, in some cases, it makes perfect sense for the workflow to let the exception bubble through. Not so that the workflow will be terminated, but rather that the message which triggered it would be tried again. You can configure Workflow Foundation to have this behavior as well, or so I&#8217;ve been told.</p>
<p>Now you&#8217;re happy, the problem&#8217;s been solved for you &#8211; by design. No need to go mucking around in the nooks and crannys of FaultHandlers, CallExternalMethodActivity, and hacking the InsertWorkflow stored procedure. </p>
<p>Clean, Correct, and Simple &#8211; courtesy of The Software Simplist.</p>
<p><u>Additional References:</u></p>
<ul>
<li><a href="http://udidahan.weblogs.us/2007/01/05/arcastnet-soa-and-workflow-with-udi-dahan/">Ron Jacobs interviews me on SOA and Workflow</a></li>
<li><a href="http://channel9.msdn.com/ShowPost.aspx?PostID=163471">A conversation on Workflow Foundation and Service Orientation</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/06/08/workflow-failures-easier-to-solve-than-ever-before/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SOA, Intermediation, and Long Running Transactions</title>
		<link>http://www.udidahan.com/2007/05/23/soa-intermediation-and-long-running-transactions/</link>
		<comments>http://www.udidahan.com/2007/05/23/soa-intermediation-and-long-running-transactions/#comments</comments>
		<pubDate>Wed, 23 May 2007 08:34:40 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Autonomous Services]]></category>
		<category><![CDATA[EDA]]></category>
		<category><![CDATA[ESB]]></category>
		<category><![CDATA[Pub/Sub]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/05/23/soa-intermediation-and-long-running-transactions/</guid>
		<description><![CDATA[In Nick Malik&#8217;s follow up post The value of intermediation, part 2, he describes &#8220;composable services&#8221; as follows:

I would suggest that a service, when composable, (a) provides information in a manner that can be readily reused without requiring multiple calls to other services for interpretation, and/or (b) provides functionality that can be executed to produce [...]]]></description>
			<content:encoded><![CDATA[<p>In Nick Malik&#8217;s follow up post <a href="http://blogs.msdn.com/nickmalik/archive/2007/05/15/the-value-of-intermediation-part-two.aspx">The value of intermediation, part 2</a>, he describes &#8220;composable services&#8221; as follows:</p>
<blockquote><p>
I would suggest that a service, when composable, (a) provides information in a manner that can be readily reused without requiring multiple calls to other services for interpretation, and/or (b) provides functionality that can be executed to produce specific semantics in an encapsulated manner without requiring references to multiple other services and without unknown or undesirable side effects.
</p></blockquote>
<p>I woud state that a service that does not comply with the above &#8220;suggestions&#8221; is not a service in the <a href="http://udidahan.weblogs.us/category/soa/">SOA sense</a>. I don&#8217;t care much for the &#8220;composable&#8221; or &#8220;reusable&#8221; qualifiers that are being placed on the term &#8220;service&#8221;. I believe that it creates fractured definitions that don&#8217;t improve understanding.</p>
<p>Nick continues with assertions about the connection between SOA and Canonical Data Models:</p>
<blockquote><p>
I argue, passionately, that a service that does not leverage a Canonical data model (explicit or implicit) is not useful outside a small handful of very specific situations.  Such a limited service provides some small benefits, but probably not more than a COM+ component would, and certainly not enough to justify all this interest in SOA.  We get no business agility from this kind of service.  Therefore, as an Enterprise Architect, you can create it, but I will not use it, nor will I look kindly on another application that does.  Poor integration is just barely a half step up from no integration.  Some would argue it is a step down.
</p></blockquote>
<p>Just to be clear, a Canonical Data Model is something that exists without dependence on any service. That is why I don&#8217;t agree with its use in SOA. Each service has its own message schema which makes use of its own data schema if you will. A data schema is the definition of structures that are used in more than one message type. The service controlls both of these schemas and decides when and how to version them, which versions to support on which endpoints, etc. It&#8217;s all part of the service&#8217;s autonomy. I&#8217;m not quite sure what an implicit canonical data model is.</p>
<p>I&#8217;m also unclear as to the &#8220;benefit&#8221; a service provides. Services are the way we model our business domain &#8211; they are therefore a part of our business. In my previous post on <a href="http://udidahan.weblogs.us/2007/05/19/on-intermediation-and-soa/">intermediation and SOA</a> I gave an example of a Purchasing Service. This service does not really exist to provide something external to it with a &#8220;benefit&#8221;, it&#8217;s an inherent part of the structure of the business, much like the Purchasing Department of the company is. It participates in business processes but is not ruled by them. I really don&#8217;t see how you could compare that to any kind of technological component. In that respect, you don&#8217;t &#8220;use&#8221; a service. Neither do you really &#8220;integrate&#8221; them. Each service decides which processes it needs to be a part of, simply by choosing which events (of the <a href="http://udidahan.weblogs.us/category/eda/">EDA kind</a>) it subscribes to. This leads to a kind of &#8220;distributed integration&#8221; that maintains service autonomy and has no single point of versioning or failure.</p>
<p>One of the comments quoted includes the statement <i>&#8220;Intermediation greatly complicates any message exchange pattern other than request-response and pub-sub&#8221;</i>. Like I described in my <a href="http://udidahan.weblogs.us/2007/05/19/on-intermediation-and-soa/">previous post</a>, intermediation, if it even does occur, occurs behind service boundaries. Between services, you have the basic message exchange patterns of duplex request/response (one way messaging each time, with correlation between them) and <a href="http://udidahan.weblogs.us/category/pub-sub/">pub/sub</a>. You really don&#8217;t need anything else, and yesterday&#8217;s middleware already handled all of that for us. Most of the advanced <a href="http://udidahan.weblogs.us/category/esb/">ESB</a> functionality isn&#8217;t needed between services.</p>
<p>The next example given discusses a banking scenario (well, more of an HR one really), which brings Nick to the following conclusion:</p>
<blockquote><p>
This process is neither pub-sub nor request-response.  It is a long-running orchestration with compensating events.  The process is NOT complicated by the ability to intermediate.  </p>
<p>In fact, I would argue that nearly all valuable long running transactions MUST have the ability to intermediate in order to allow them to be composed, and recomposed, and orchestrated.
</p></blockquote>
<p>Long running anything, is a series of message exchanges that are tied together in some way. This could be as simple as having all the messages contain the same process ID in their body. &#8220;Compensating events&#8221; are just the result of business logic being run in a service, possibly changing its own state (updating those backend systems and applications), and sending out other messages. If there&#8217;s any intermediation of the kind Nick describes, it occurs within a service between its backend systems and applications. He also implicitly states that there is value in composing/orchestrating these &#8220;long running transactions&#8221;, apparently without having the service be involved. I don&#8217;t see it. Not the way I do my services. Once again, each service is responsible for itself &#8211; its part of the global &#8220;long running transaction&#8221;, ie business process. If one service were to choose to implement its cross-application workflows in a hard-coded manner, that should have no impact on any other services, nor should they be aware of it. That service may have been implemented poorly and as a result have difficulty responding to changing business conditions quickly, but that&#8217;s its own business. That implementation could easily be upgraded in the future, without changing the overall Service-Oriented Architecture.</p>
<p>Nick&#8217;s conclusion follows:</p>
<blockquote><p>
In conclusion, I don&#8217;t say that intermediation is a requirement of a service oriented architecture.  But I do say that intermediation is a requirement of a service oriented architecture designed to deliver composability, and therefore, business agility.
</p></blockquote>
<p>Mine is a little different. When your SOA is made up of autonomous business-level services, you will have business agility. The implementations of some services may benefit through the use of intermediation, but it is not a top level concern.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/05/23/soa-intermediation-and-long-running-transactions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thoughts about workflow foundation</title>
		<link>http://www.udidahan.com/2007/01/05/thoughts-about-workflow-foundation/</link>
		<comments>http://www.udidahan.com/2007/01/05/thoughts-about-workflow-foundation/#comments</comments>
		<pubDate>Sat, 06 Jan 2007 00:08:00 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/archives/362</guid>
		<description><![CDATA[After spending a good week at TechEd Developers in Barcelona, going to some of the sessions, having a late-night chat with the WF product guys, and some general blue-sky thinking, my thoughts around workflow foundation have begun to crystallize.
I know that WF was designed to be general purpose, but I don&#8217;t like general purpose tools, [...]]]></description>
			<content:encoded><![CDATA[<p>After spending a good week at TechEd Developers in Barcelona, going to some of the sessions, having a late-night chat with the WF product guys, and some general blue-sky thinking, my thoughts around workflow foundation have begun to crystallize.</p>
<p>I know that WF was designed to be general purpose, but I don&#8217;t like general purpose tools, not for the projects I work on. I don&#8217;t like that it has its own threading model and that I have to override it. I don&#8217;t like that it has its own activation model and that I have to override it too. These are architectural concerns that need to be in sync with the entire project &#8211; I can&#8217;t have every part of the system doing its own thing.</p>
<p>Although not surprised, I was a bit saddened when I was sitting through the <a href="http://blogs.msdn.com/ironarchitect/">Iron Architect </a>contest and each participant described how they would implement the business logic of the system with WF. Personally, I think that that&#8217;s a bad choice. <a href="http://udidahan.weblogs.us/2007/04/21/domain-model-pattern/">Object-oriented domain models</a> do an excellent job of modelling <a href="http://udidahan.weblogs.us/category/business-rules/">complex business logic</a>. The procedure-oriented nature of workflows predisposes them to the historic failures that method has brought in the past.</p>
<p>One area where I can&#8217;t think why WF wouldn&#8217;t do well in is for web-based page navigation. I&#8217;m sure there are others, but for the systems I work on there are usually better alternatives in those areas. When it comes to products, on the other hand, WF might be a smash. I&#8217;m pretty sure that the Sharepoint guys are betting the farm on WF for the human workflow there. Again, since I&#8217;m a project guy and not a product guy I don&#8217;t think I can do WF justice there.</p>
<p>One area I&#8217;m really interested in is long-running workflows and their use in <a href="http://udidahan.weblogs.us/category/soa/">SOA</a>. WF has a very important, and non-trivial thing called Persistent Timers in this area. This is incredibly important if you need your workflows to continue to be correct even in the event of a server restart, I know I do. WF supports a number of scenarios in terms of communication that currently don&#8217;t interest me but I am looking forward to seeing how their going to support <a href="http://udidahan.weblogs.us/category/wcf/">WCF&#8217;s</a> duplex communication patterns.</p>
<p>All in all, WF is an intersting bit of technology that I will continue watching as it evolves.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/01/05/thoughts-about-workflow-foundation/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ARCast.net &#8211; SOA and Workflow with Udi Dahan</title>
		<link>http://www.udidahan.com/2007/01/05/arcastnet-soa-and-workflow-with-udi-dahan/</link>
		<comments>http://www.udidahan.com/2007/01/05/arcastnet-soa-and-workflow-with-udi-dahan/#comments</comments>
		<pubDate>Fri, 05 Jan 2007 23:49:22 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[Podcast]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://udidahan.weblogs.us/archives/361</guid>
		<description><![CDATA[Get it here.
[Salt and Pepper, Peanut Butter and Jelly, Toast and Vegemite (if your down under) - these are all things that go together. But what goes with SOA you ask? Why Workflow of course! On this episode we are joined by Microsoft Archtiect MVP Udi Dahan who gives us his insight into putting these [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.skyscrapr.net/blogs/arcasts/archive/2006/12/28/598.aspx">Get it here.</a></p>
<p>[Salt and Pepper, Peanut Butter and Jelly, Toast and Vegemite (if your down under) - these are all things that go together. But what goes with SOA you ask? Why Workflow of course! On this episode we are joined by Microsoft Archtiect MVP Udi Dahan who gives us his insight into putting these two technologies together.]</p>
<p>I just can&#8217;t seem to shut up about these things. It&#8217;s gotten so bad that I&#8217;ll be inflicting the same session I gave in TechEd Developers Europe on our local Israeli crowd at the end of this month. You can find out what other horrors Microsoft has in store <a href="http://www.microsoft.com/israel/msdn/academy/default.mspx">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2007/01/05/arcastnet-soa-and-workflow-with-udi-dahan/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>.Net 2.0 no big deal?</title>
		<link>http://www.udidahan.com/2006/10/05/net-20-no-big-deal/</link>
		<comments>http://www.udidahan.com/2006/10/05/net-20-no-big-deal/#comments</comments>
		<pubDate>Thu, 05 Oct 2006 11:36:36 +0000</pubDate>
		<dc:creator>thesoftwaresimplist</dc:creator>
				<category><![CDATA[BizTalk]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[OO]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://wp_630.weblogs.us/archives/327</guid>
		<description><![CDATA[Jesse seems to be swallowing the Microsoft party line without missing a drop in his latest post <a href="http://weblogs.asp.net/jezell/archive/2006/10/05/Screw-2.0_2C00_-I_2700_m-Going-Straight-to-3.0.aspx">Screw 2.0, I'm Going Straight to 3.0</a>. 
<br/><br/>
From his post:
<br/><br/>
<em>
"The 2.0 framework doesn't really give you a massive amount of really new really cool features. There is one-click, which we probably wouldn't use anyway, generics (which are useful as a time saver, but don't really do much that you can't do without them), and some other little features... but the best part about the 2.0 framework is probably the IDE/dev experience, not what customers get out of it."
</em>
<br/><br/>
Granted, One-Click is nothing to write home about, but the runtime level additions, they just totally changed the way I write code. I'm talking about generics, anonymous methods, delegate inference, and the rest. The rest of 2.0, like the enhancements of the provider model in ASP.Net, well you would have developed the same kind of framework yourself if you were doing serious web development.
<br/><br/>
The whole 3.0 story, I've got to tell you, I'm pretty underwhelmed. Everybody seems to be jumping up and down about WPF, and yes, it's new and shiny, but there still the clunkety Windows message pump in the background. No real changes in how you're going to write multi-threaded UIs, which seem to be the real future given the rise in multi-core processing. The visual aspects of client side code in the systems I write run at around 5% of the overall effort. So the UI will look better, I dunno, 4D buttons and stuff, sorry for not falling over with enthusiasm.
<br/><br/>
And then there's WCF. Ah, wait, no publish/subscribe. Bummer, most of my systems being asynchronous in nature are built on the pub/sub model. An OO interface for interprocess communication? Who wants it - I need a message-based interface.
<br/><br/>
Don't forget WF - what was that for again? The main place where WF can fit my needs is for handling long-running workflows between systems, since I don't use Biztalk. But the performance of WF doesn't seem to fit this environment, it seems to be more suited for human workflow times. 
<br/><br/>
If anything, I'd have to say that .Net 2.0 was a relatively big deal. 3.0 will probably be just as important with the runtime level enhancements like lambda expressions, extension methods, anonymous types, and implicitly typed variables. All the rest of the hyped up stuff in 3.0, I don't really expect it to change anything in how I work today.]]></description>
			<content:encoded><![CDATA[<p>Jesse seems to be swallowing the Microsoft party line without missing a drop in his latest post <a href="http://weblogs.asp.net/jezell/archive/2006/10/05/Screw-2.0_2C00_-I_2700_m-Going-Straight-to-3.0.aspx">Screw 2.0, I&#8217;m Going Straight to 3.0</a>. </p>
<p>From his post:</p>
<p><em><br />
&#8220;The 2.0 framework doesn&#8217;t really give you a massive amount of really new really cool features. There is one-click, which we probably wouldn&#8217;t use anyway, generics (which are useful as a time saver, but don&#8217;t really do much that you can&#8217;t do without them), and some other little features&#8230; but the best part about the 2.0 framework is probably the IDE/dev experience, not what customers get out of it.&#8221;<br />
</em></p>
<p>Granted, One-Click is nothing to write home about, but the runtime level additions, they just totally changed the way I write code. I&#8217;m talking about generics, anonymous methods, delegate inference, and the rest. The rest of 2.0, like the enhancements of the provider model in ASP.Net, well you would have developed the same kind of framework yourself if you were doing serious web development.</p>
<p>The whole 3.0 story, I&#8217;ve got to tell you, I&#8217;m pretty underwhelmed. Everybody seems to be jumping up and down about WPF, and yes, it&#8217;s new and shiny, but there still the clunkety Windows message pump in the background. No real changes in how you&#8217;re going to write multi-threaded UIs, which seem to be the real future given the rise in multi-core processing. The visual aspects of client side code in the systems I write run at around 5% of the overall effort. So the UI will look better, I dunno, 4D buttons and stuff, sorry for not falling over with enthusiasm.</p>
<p>And then there&#8217;s WCF. Ah, wait, no publish/subscribe. Bummer, most of my systems being asynchronous in nature are built on the pub/sub model. An OO interface for interprocess communication? Who wants it &#8211; I need a message-based interface.</p>
<p>Don&#8217;t forget WF &#8211; what was that for again? The main place where WF can fit my needs is for handling long-running workflows between systems, since I don&#8217;t use Biztalk. But the performance of WF doesn&#8217;t seem to fit this environment, it seems to be more suited for human workflow times. </p>
<p>If anything, I&#8217;d have to say that .Net 2.0 was a relatively big deal. 3.0 will probably be just as important with the runtime level enhancements like lambda expressions, extension methods, anonymous types, and implicitly typed variables. All the rest of the hyped up stuff in 3.0, I don&#8217;t really expect it to change anything in how I work today.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2006/10/05/net-20-no-big-deal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
