<?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>Eric Hauser's Blog &#187; Idempotent</title>
	<atom:link href="http://erichauser.net/tag/idempotent/feed/" rel="self" type="application/rss+xml" />
	<link>http://erichauser.net</link>
	<description>J2EE, .NET, and general technology</description>
	<lastBuildDate>Fri, 23 Apr 2010 05:00:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>NServiceBus Facility Enhancements</title>
		<link>http://erichauser.net/2008/08/23/nservicebus-facility-enhancements/</link>
		<comments>http://erichauser.net/2008/08/23/nservicebus-facility-enhancements/#comments</comments>
		<pubDate>Sat, 23 Aug 2008 14:59:41 +0000</pubDate>
		<dc:creator>ehauser</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Castle]]></category>
		<category><![CDATA[Idempotent]]></category>
		<category><![CDATA[NServiceBus]]></category>

		<guid isPermaLink="false">http://erichauser.net/?p=62</guid>
		<description><![CDATA[I have added a couple of additions to Ayende&#8217;s NServiceBus Facility:

Message handlers and sagas are automatically registered with the container for the defined assemblies
Message handlers are proxied
You can register IHandlerFilter instances with the kernel that allow for interception of messages as they are processed
Using my replay strategy implementation, you can decorate a message handler as [Idempotent(Attemps = 5, [...]]]></description>
			<content:encoded><![CDATA[<p>I have added a couple of additions to <a title="NServiceBus Facility" href="http://www.ayende.com/Blog/archive/2008/07/13/Putting-the-container-to-work-Refactoring-NServiceBus-configuration.aspx">Ayende&#8217;s NServiceBus Facility</a>:</p>
<ul>
<li>Message handlers and sagas are automatically registered with the container for the defined assemblies</li>
<li>Message handlers are proxied</li>
<li>You can register IHandlerFilter instances with the kernel that allow for interception of messages as they are processed</li>
<li>Using my replay strategy implementation, you can decorate a message handler as [Idempotent(Attemps = 5, Delay = 2000)].  That means that a message will be retried when an exception is thrown processing the message 5 times, delaying 2 seconds between each retry.  This could also be extended so that depending on the type of exception that is being thrown, a default retry strategy is applied.</li>
</ul>
<p><a href="http://erichauser.net/wp-content/uploads/idempotent_attribute1.jpg"><img class="alignnone size-full wp-image-71" title="idempotent_attribute1" src="http://erichauser.net/wp-content/uploads/idempotent_attribute1.jpg" alt="" /></a></p>
<ul>
<li>The bus is started automatically once all handler dependencies have been satisfied</li>
</ul>
<p>There were a couple of interesting things that I found when implementing this.  One, NServiceBus retrieives handlers from the kernel using the concrete class instance (looking back Ayende noted this as &#8220;yuck&#8221;).  That means that we cannot proxy the interface, but instead have to create a class proxy for our message handlers.  That means that when we the message handlers, we have to verify that the message handler methods are virtual and give a nice error if they are not:</p>
<p><a href="http://erichauser.net/wp-content/uploads/registerhandlers.jpg"><img class="alignnone size-full wp-image-65" title="registerhandlers" src="http://erichauser.net/wp-content/uploads/registerhandlers.jpg" alt="" /></a></p>
<p>Very easy to do with Castle&#8217;s fluent interface for registration.  Sagas, on the other hand, have to be registered in the container by each of their interfaces because saga instances are retrieve by calling builder.Build&lt;ISaga&lt;SomeMessage&gt;&gt;().</p>
<p>Out of the box, the way to do message interception with NSB is to have message handlers chained in a specified order.  The IHandlerFilter provides another method for message interception.  If you have a new filter to add, all you have to do is register the IHandlerFilter instance with the container:</p>
<p><a href="http://erichauser.net/wp-content/uploads/handlerfilter1.jpg"><img class="alignnone size-full wp-image-67" title="handlerfilter1" src="http://erichauser.net/wp-content/uploads/handlerfilter1.jpg" alt="" /></a></p>
<p>The filters follow the chain of responsibility pattern, so they can be short circuited &#8212; which is the same as calling bus.DoNotContinueDispatchingCurrentMessageToHandlers().</p>
<p>I have attached the updates to the post: <a href="http://erichauser.net/wp-content/uploads/nservicebus-fullduplex-xml-update.zip">nservicebus-fullduplex-xml-update</a>.  Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://erichauser.net/2008/08/23/nservicebus-facility-enhancements/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
