<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-288124269083996844</id><updated>2012-02-16T02:42:26.916-08:00</updated><category term='NServiceBus'/><category term='Powershell'/><category term='CQRS'/><category term='REST'/><category term='MSDTC'/><category term='MSMQ'/><category term='Modeling'/><category term='Saga'/><category term='Distributor'/><category term='Oracle AQS'/><category term='Virtualization'/><category term='Scaling'/><category term='Profiles'/><title type='text'>On the Bus</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>45</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-2494291999875070608</id><published>2012-01-12T05:54:00.000-08:00</published><updated>2012-01-12T05:55:11.628-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='REST'/><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><title type='text'>JSON Serializer in NSB 3.0</title><content type='html'>I was answering a question over on SO and I discovered that there is a JSON/BSON serializer built-in to 3.0. It seems like it would be possible with a a bit more digging that you could build upon my &lt;a href="http://adamfyles.blogspot.com/2010/08/exposing-nservicebus-as-restwcf.html"&gt;hack to expose NSB as a REST endpoint&lt;/a&gt; and skip the WCF serialization and jump right down into NSB(assuming WCF is configured to use the JSON format).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-2494291999875070608?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/2494291999875070608/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2012/01/json-serializer-in-nsb-30.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/2494291999875070608'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/2494291999875070608'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2012/01/json-serializer-in-nsb-30.html' title='JSON Serializer in NSB 3.0'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-6991492314383356216</id><published>2011-12-27T12:38:00.000-08:00</published><updated>2012-01-12T05:55:24.881-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><title type='text'>NServiceBus Modeling Tools Review</title><content type='html'>After downloading and installing the package, the first thing that we have to do is create a new NSB application.  So where is it?  I expected it to be in a custom NServiceBus folder under Visual C#, but it wasn't.  Then I tried Windows thinking that since we deploy as a Windows Service, it would be there.  Nope.  Modeling Projects?  Nope.  So then I did a search and found it at the Visual C# root.  I eventually found it, but I'm hoping this moves somewhere more obvious.  I'm also curious about the term "application".  In the Advanced Distributed System Design course we talked at length on how an application is something that does not require network access, something like Microsoft Word.  I'm thinking this should be changed to "System" instead.  &lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-bfN4mMXIZNg/Tvor1j1GHlI/AAAAAAAABeo/YByExfX8c2Y/s1600/NewProjectPage.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="441" src="http://1.bp.blogspot.com/-bfN4mMXIZNg/Tvor1j1GHlI/AAAAAAAABeo/YByExfX8c2Y/s640/NewProjectPage.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;It takes you right into the designer canvas which is nice.  In the toolbox we have a pretty small set of items, a couple of message types, matching connectors, and two endpoints.  I'm going to try to set up a simple send-only client that in turn publishes to a couple of subscribers.  &lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-pwUjGFMhYJ4/TvosLr6w6eI/AAAAAAAABe0/2Y4iCVjkj8U/s1600/pubsub2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="400" src="http://3.bp.blogspot.com/-pwUjGFMhYJ4/TvosLr6w6eI/AAAAAAAABe0/2Y4iCVjkj8U/s400/pubsub2.png" width="366" /&gt;&lt;/a&gt;&lt;/div&gt;Somehow my references are busted, so I opened the project to see the path and it's referencing some MSBuild variable, so I just updated all the refs.  I'm not sure what the bug is here, but I'll blow right by it.  &lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-x6DjtG5N2ro/TvosZKlRMGI/AAAAAAAABfA/Zf8KfEBY50k/s1600/BustedReferences.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="400" src="http://2.bp.blogspot.com/-x6DjtG5N2ro/TvosZKlRMGI/AAAAAAAABfA/Zf8KfEBY50k/s400/BustedReferences.png" width="197" /&gt;&lt;/a&gt;&lt;/div&gt;Now that we've generated the system, let's go and see what it did.  So far the Client looks just fine:  &lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-CVo7sXJVEU4/TvoscvMkCII/AAAAAAAABfM/1Xn2ea_BQ3I/s1600/client.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="116" src="http://3.bp.blogspot.com/-CVo7sXJVEU4/TvoscvMkCII/AAAAAAAABfM/1Xn2ea_BQ3I/s400/client.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;All the message classes look fine and I'm glad to see that the commands are separated from the events into different assemblies.  I'm also glad to see that the Publisher is defined correctly:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-3mThj_H9Aj8/TvosgC46yZI/AAAAAAAABfY/rrICf47NJQc/s1600/publisher.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="116" src="http://3.bp.blogspot.com/-3mThj_H9Aj8/TvosgC46yZI/AAAAAAAABfY/rrICf47NJQc/s400/publisher.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;I didn't think it would do that based on the canvas.  I would like to see a larger group of endpoints that are defined based on there role.  This would include Publisher, Subscriber, Distributor, Worker, and Server.  This would make it very obvious to the beginner what they are building.  The Subscribers are also defined correctly:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-1avm3j3MQpg/TvoskAq7MCI/AAAAAAAABfk/TYScobvanFA/s1600/subscriber.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="118" src="http://4.bp.blogspot.com/-1avm3j3MQpg/TvoskAq7MCI/AAAAAAAABfk/TYScobvanFA/s400/subscriber.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;It would also be nice if the endpoint configuration matched what was on the canvas, in this case that would be "AsA_Subscriber".  Most people that I've helped to learn NSB get a little caught up on what the endpoints can do.  If we added "AsA_Subscriber" we could also do some validation on the subscription itself(depending on the profile).All in all, this is a huge step forward.  Congratulations to the team for significantly lowering the barrier to entry to getting started.  I'd like to see some of the refinements I mentioned above and also would like some Distributor support(I'm sure that is on the list).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-6991492314383356216?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/6991492314383356216/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2011/12/nservicebus-modeling-tools-review.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/6991492314383356216'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/6991492314383356216'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2011/12/nservicebus-modeling-tools-review.html' title='NServiceBus Modeling Tools Review'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-bfN4mMXIZNg/Tvor1j1GHlI/AAAAAAAABeo/YByExfX8c2Y/s72-c/NewProjectPage.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-5494237249419115004</id><published>2011-12-20T14:18:00.001-08:00</published><updated>2012-01-12T05:55:38.638-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><title type='text'>NServiceBus 3.0 Beta 1</title><content type='html'>You can download 3.0 from &lt;a href="http://nservicebus.com/Downloads.aspx"&gt;here&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-5494237249419115004?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/5494237249419115004/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2011/12/nservicebus-30-beta-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/5494237249419115004'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/5494237249419115004'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2011/12/nservicebus-30-beta-1.html' title='NServiceBus 3.0 Beta 1'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-4725632814755745466</id><published>2011-10-31T06:05:00.000-07:00</published><updated>2011-10-31T06:05:14.322-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><category scheme='http://www.blogger.com/atom/ns#' term='Modeling'/><title type='text'>NServiceBus Modeling Tools Video</title><content type='html'>I just gave this a look and the tools really lower the barrier to entry to "getting on the bus".  I'm going to take some time this week and give it a full evaluation and I'll post that back here.  For now, enjoy the video.&lt;br /&gt;&lt;br /&gt;&lt;iframe src="http://player.vimeo.com/video/29659143?byline=0&amp;amp;portrait=0" width="400" height="225" frameborder="0" webkitAllowFullScreen allowFullScreen&gt;&lt;/iframe&gt;&lt;p&gt;&lt;a href="http://vimeo.com/29659143"&gt;NServiceBus Modeling Tools for Visual Studio&lt;/a&gt; from &lt;a href="http://vimeo.com/user8685263"&gt;NServiceBus Ltd.&lt;/a&gt; on &lt;a href="http://vimeo.com"&gt;Vimeo&lt;/a&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-4725632814755745466?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/4725632814755745466/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2011/10/nservicebus-modeling-tools-video.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/4725632814755745466'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/4725632814755745466'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2011/10/nservicebus-modeling-tools-video.html' title='NServiceBus Modeling Tools Video'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-631341973447345197</id><published>2011-07-21T11:04:00.000-07:00</published><updated>2011-07-21T11:04:15.037-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Distributor'/><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><category scheme='http://www.blogger.com/atom/ns#' term='Virtualization'/><title type='text'>The Great Worker Pile Up Problem: Solved!</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-MLKCfZ9PWi8/TihneV9lYJI/AAAAAAAAA4U/-P8UGYjXFLk/s1600/PileUp.jpg" imageanchor="1" style="clear:left; float:left;margin-right:1em; margin-bottom:1em"&gt;&lt;img border="0" height="216" width="320" src="http://1.bp.blogspot.com/-MLKCfZ9PWi8/TihneV9lYJI/AAAAAAAAA4U/-P8UGYjXFLk/s320/PileUp.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;In our configuration of the Distributor pattern, we have the Distributor clustered across multiple VMs.  We also run Workers on separate nodes in the same cluster.  We are doing this so that we can deploy the same image to all nodes.  With this configuration any Distributor/Worker can move from one node to the other in case of a failure.  With all this sliding of nodes around we ran into one main issue.&lt;br /&gt;&lt;br /&gt;Everything worked great up until we had the big pile up.  What would happen is we would intentionally drop all the nodes in succession until we got down to one node.  Usually this node would have the Distributor already there and Worker1 would slide over.  No problems.  When Worker2 slid over to that node all of a sudden one of the Workers would take itself out of business, all the work would move to the other Worker and then we'd have a couple messages disappear.  Disappear temporarily that is.  Eventually they would come back and be processed.  &lt;br /&gt;&lt;br /&gt;We initially thought this was due to MSDTC since we saw messages that weren't get ack'd hanging out.  After chasing this awhile we then figured it must be some networking issue.  Like just about any clustered VM we have 2 NICs configured on the VM, one for the SAN and one for everything else.  Come to find out when the last Worker slid over, it was picking up the NIC for the SAN and not the general network.  Therefore the messages weren't getting ack'd, but eventually they'd find their way back.&lt;br /&gt;&lt;br /&gt;We tried setting the priority of the NICs and so on to no avail.  After speaking with MS, we ended up pinning the IPs of the local machines in the registry to the correct network interface.  We also had to do this on the clustered services as well.  Now when the nodes slide about the local IPs don't change and we have a script that the services depend on that updates the clustered IPs if necessary(like when you change data centers).&lt;br /&gt;&lt;br /&gt;I'd like to that our team for being persistent and finally tracking this one down.  Now we can deploy the same image to all nodes and have them move about freely.  Everything works as designed with full load balancing.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-631341973447345197?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/631341973447345197/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2011/07/great-worker-pile-up-problem-solved.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/631341973447345197'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/631341973447345197'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2011/07/great-worker-pile-up-problem-solved.html' title='The Great Worker Pile Up Problem: Solved!'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-MLKCfZ9PWi8/TihneV9lYJI/AAAAAAAAA4U/-P8UGYjXFLk/s72-c/PileUp.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-2403689827326956875</id><published>2011-05-06T05:56:00.000-07:00</published><updated>2011-05-06T05:56:17.963-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><title type='text'>Introducing NServiceBus Visual Studio Templates</title><content type='html'>I really got tired of creating the same projects over and over so I decided to create some templates.  I packaged them up and put them on the Visual Studio Gallery: &lt;a href="http://visualstudiogallery.msdn.microsoft.com/9546d382-7ffa-4fb8-8c0f-b7825d5fd085"&gt;http://visualstudiogallery.msdn.microsoft.com/9546d382-7ffa-4fb8-8c0f-b7825d5fd085&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Right now it only includes a few project templates and a few items.  If you are using the project templates there is a custom wizard that will prompt you for a path to the NSB binaries.  This will auto adjust the HintPath in the project file to point to that directory.  &lt;br /&gt;&lt;br /&gt;I'm planning on adding more endpoints and some complete solutions in the near future.  Let me know what you are looking for via the gallery so I can keep track of it there.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-2403689827326956875?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/2403689827326956875/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2011/05/introducing-nservicebus-visual-studio.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/2403689827326956875'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/2403689827326956875'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2011/05/introducing-nservicebus-visual-studio.html' title='Introducing NServiceBus Visual Studio Templates'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-628107090320713850</id><published>2011-04-27T11:06:00.000-07:00</published><updated>2011-04-27T11:06:27.836-07:00</updated><title type='text'>More Reasons Working with NServiceBus is Just Easier than WCF over MSMQ</title><content type='html'>We have some teams that went down the route of using WCF over MSMQ.  Using a durable transport was the right thing to do for their process(accepting orders).  We ran into a few issues along the way and had we used NSB to start with, we would have just avoided them.&lt;br /&gt;&lt;br /&gt;IIS/WAS Hosting&lt;br /&gt;&lt;br /&gt;We *thought* this would be a no brainer, but it really wasn't.  Come to find out, if something goes wrong or your app pool recycles(every 24 hours or so guaranteed), you need to "warm-up" the service before it accepts messages.  So Microsoft's answer to this is a warm-up extension to IIS or to host the service as a Windows Service.  I think hosting in a Windows Service is a much better idea anyway as we weren't really using any of the IIS features anyway on the MSMQ transport.  The thing is, had we used NSB out of the box we'd never have encountered such an issue.&lt;br /&gt;&lt;br /&gt;Windows Service Hosting&lt;br /&gt;&lt;br /&gt;Hosting this way gets you out of the warm-up jam.  Unfortunately there is another problem if your shop uses SCOM like we do for monitoring.  We haven't been able to get SCOM to monitor on the poison sub queues that WCF creates to put bad messages.  We have some choices, which are call on MS to get this to work, build our own monitor, or just switch to NSB.  I prefer the latter as we already have plenty of endpoints that we monitor just fine.&lt;br /&gt;&lt;br /&gt;Summary&lt;br /&gt;&lt;br /&gt;If you are thinking of using WCF over MSMQ make sure you host in a windows service and have a plan for when bad things happen.  To us it makes sense to just retrofit those endpoints to NSB and avoid all the issues completely.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-628107090320713850?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/628107090320713850/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2011/04/more-reasons-working-with-nservicebus.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/628107090320713850'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/628107090320713850'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2011/04/more-reasons-working-with-nservicebus.html' title='More Reasons Working with NServiceBus is Just Easier than WCF over MSMQ'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-7663185026887705145</id><published>2011-04-06T16:56:00.000-07:00</published><updated>2011-04-06T16:56:49.734-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><title type='text'>NServiceBus Customization Part 2: IWantToRunAtStartup</title><content type='html'>When NSB starts up it will look for all implementors of the interface IWantToRunAtStartup and call their Run() methods. &amp;nbsp;When NSB spins down it will also call the Stop() method of the same interface. &amp;nbsp;This gives us a good place to run expensive one time initialization code or to tweak out the bus prior to getting going. &amp;nbsp;A common usage of this interface is for the manual subscription to specific message types:&lt;br /&gt;&lt;pre class="brush:c#"&gt;public IBus Bus { get; set; }&lt;br /&gt;&lt;br /&gt;        #region IWantToRunAtStartup Members&lt;br /&gt;&lt;br /&gt;        public void Run()&lt;br /&gt;        {&lt;br /&gt;            this.Bus.Subscribe&amp;lt;IProductUpdatedEvent&amp;gt;();&lt;br /&gt;            this.Bus.Subscribe&amp;lt;IProductCreatedEvent&amp;gt;();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public void Stop()&lt;br /&gt;        {&lt;br /&gt;            this.Bus.Unsubscribe&amp;lt;IProductUpdatedEvent&amp;gt;();&lt;br /&gt;            this.Bus.Unsubscribe&amp;lt;IProductCreatedEvent&amp;gt;();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        #endregion&lt;br /&gt;&lt;/pre&gt;One thing that I would caution against doing in the Run() method is not exiting the method.  I've seen cases where someone will go into an infinite loop and never exit Run().  Typically this is done to perform a task on a given interval.  There are much better ways to do this, mostly commonly you can put a Timer into the container and wire into its events.  If you never leave the Run() method, the Bus doesn't ever really startup and you will get some odd results.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-7663185026887705145?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/7663185026887705145/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2011/04/nservicebus-customization-part-2.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/7663185026887705145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/7663185026887705145'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2011/04/nservicebus-customization-part-2.html' title='NServiceBus Customization Part 2: IWantToRunAtStartup'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-3512562275452982447</id><published>2011-04-01T05:48:00.000-07:00</published><updated>2011-04-01T05:48:38.620-07:00</updated><title type='text'>NServiceBus 3.0 Details</title><content type='html'>The following content is paraphrased from the &lt;a href="http://tech.dir.groups.yahoo.com/group/nservicebus/message/10357"&gt;Yahoo Group&lt;/a&gt;:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="MsoNormal" style="clear: both; font-family: Georgia; font-size: 11pt; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 15px;"&gt;&lt;b&gt;First of all&lt;/b&gt;, I'd like to talk about the thing that will influence you the most. We're making every effort to make the use of NServiceBus (particularly it's auxiliary processes like the Timeout Manager, Distributor, and Gateway) much, much easier. What this means is removing much of complexity of using these capabilities by hosting them within the same host as your own process, but don't worry, we'll make it easy for you to turn them on and off using profiles. This will enable us to configure all the routing to these processes for you, but if you want, you can always go back to the manual approach in version 2.x. This is where I'll be investing most of my time.&lt;o&gt;&lt;/o&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="clear: both; font-family: Georgia; font-size: 11pt; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 15px;"&gt;&lt;o&gt;&amp;nbsp;&lt;/o&gt;&lt;b&gt;Second&lt;/b&gt;, there's the Data Bus feature that Andreas Öhlund (&lt;a href="http://andreasohlund.net/" style="color: blue; text-decoration: underline;"&gt;http://andreasohlund.net/&lt;/a&gt;) has been working on. As many of you know, most queuing transports have a limit on the size of message they can deliver - with MSMQ this is 4MB, with Azure it's 8KB. The Data Bus will allow you to transmit messages of an almost arbitrary size as it transmits the "data" portion on a separate infrastructure than the actual message. This is currently implemented using the file system but will be done using a database (RavenDB) as well - more on that in just a minute. The thing is that between remote sites, there often isn't the ability to have a shared file system or database, as the sites may not always be connected to each other. In order to resolve this issue, Andreas is also working on the Gateway to make it Data Bus aware - that and also able to support transports other than HTTP, like TCP and FTP.&lt;/div&gt;&lt;div class="MsoNormal" style="clear: both; font-family: Georgia; font-size: 11pt; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 15px;"&gt;&lt;o&gt;&lt;/o&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="clear: both; font-family: Georgia; font-size: 11pt; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 15px;"&gt;&lt;o&gt;&amp;nbsp;&lt;/o&gt;&lt;b&gt;Third&lt;/b&gt;, there's the Azure integration that Yves Goeleven has been driving for some time now. For all those of you who've been looking for a simpler developer experience on Azure, Yves has really done it, abstracting away almost all of the underlying complexity behind your standard NServiceBus interfaces. You can find out more about this through his series of blog posts here:&lt;a href="http://cloudshaper.wordpress.com/" style="color: blue; text-decoration: underline;"&gt;http://cloudshaper.wordpress.com/&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="MsoNormal" style="clear: both; font-family: Georgia; font-size: 11pt; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 15px;"&gt;&lt;b&gt;Fourth&lt;/b&gt;&amp;nbsp;is RavenDB integration. I'm happy to say that a licensing agreement has been reached that will allow users of NServiceBus Standard Edition to use RavenDB for things like Subscription Storage and Saga Persistence at no additional cost. This will save you from having to haggle with your DBAs anytime you want production-ready storage for NServiceBus - it'll give you a much more cohesive deployment without worrying about overloading your existing relational databases. I'm happy to welcome one of our newest committers, Jonathan Matheus (&lt;a href="http://www.linkedin.com/in/jonathanmatheus" style="color: blue; text-decoration: underline;"&gt;http://www.linkedin.com/in/jonathanmatheus&lt;/a&gt;), who is making this happen.&lt;o&gt;&lt;/o&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="clear: both; font-family: Georgia; font-size: 11pt; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 15px;"&gt;&lt;o&gt;&amp;nbsp;&lt;/o&gt;The integration of RavenDB will enable us to stop merging NHibernate, but we'll still integrate with it out of the box. This will make it much easier for you to plug in your own version of NH instead of ours.&lt;/div&gt;&lt;div class="MsoNormal" style="clear: both; font-family: Georgia; font-size: 11pt; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 15px;"&gt;&lt;o&gt;&lt;/o&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="clear: both; font-family: Georgia; font-size: 11pt; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 15px;"&gt;&lt;o&gt;&amp;nbsp;&lt;/o&gt;&lt;b&gt;Fifth&lt;/b&gt;&amp;nbsp;is the Timeout Manager - one of the areas of NServiceBus that hasn't been as strong as the others. Jonathan Oliver (&lt;a href="http://blog.jonathanoliver.com/" style="color: blue; text-decoration: underline;"&gt;http://blog.jonathanoliver.com/&lt;/a&gt;&amp;nbsp;who has been ramping up his involvement over the past while) will be using our new RavenDB persistence to replace the use the input queue, which will dramatically increase the performance and robustness of the Timeout Manager.&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="MsoNormal" style="clear: both; font-family: Georgia; font-size: 11pt; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 15px;"&gt;We're also looking at stronger Visual Studio integration, possibly to the level of providing model-driven code/config generation. We'll see if it's feasible to get that done within the 3.0 timeframe, or whether that will be delivered as a separate download afterwards.&lt;o&gt;&lt;/o&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="clear: both; font-family: Georgia; font-size: 11pt; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 15px;"&gt;&lt;o&gt;&amp;nbsp;&lt;/o&gt;Finally, the&amp;nbsp;&lt;b&gt;3.0 release schedule&lt;/b&gt;&amp;nbsp;looks something like this - Alpha by the end of April (primarily focusing on APIs), Beta in July, and a Release (or at least release candidate you can go live with) in September.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-3512562275452982447?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/3512562275452982447/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2011/04/nservicebus-30-details.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/3512562275452982447'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/3512562275452982447'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2011/04/nservicebus-30-details.html' title='NServiceBus 3.0 Details'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-4153506822140799596</id><published>2011-03-27T11:59:00.000-07:00</published><updated>2011-03-29T05:22:32.384-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><title type='text'>NServiceBus Customization Part 1: IWantCustomInitialization</title><content type='html'>In this first part we're going to explore how to take control of NServiceBus during the initialization phase. &amp;nbsp;By implementing the IWantCustomInitialization interface, you take full control away from NSB Roles. &amp;nbsp;What is a Role? &amp;nbsp;A Role tells an Endpoint how to participate on the bus. &amp;nbsp;Typical Roles are the Server, Client, and Publisher Roles. &amp;nbsp;These are defined by a class in your project, typically named EndpointConfig. &amp;nbsp;A Role will define certain aspects of behavior, like whether or not it can receive messages(AsA_Client). &lt;br /&gt;&lt;br /&gt;Most of the time you don't end up ever overriding the default behavior of the Roles. &amp;nbsp;When you do, you'll implement the IWantCustomInitialization interface and have full control over NServiceBus. &amp;nbsp;You will use the static NServiceBus.Configure class to get things going. &amp;nbsp;Let's take a look at all the options(as of 2.5, 3.0 follows):&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;.With()/.WithWeb()&lt;/b&gt; - these first methods give you the ability to control assembly scanning. &amp;nbsp;When NSB fires up, it will scan the bin directory by default. &amp;nbsp;This gives you control over what gets scanned. &amp;nbsp;You can provide a list of Assemblies, a list of Types, or a path. &amp;nbsp;You'll want to use the WithWeb() version if you are using NSB with ASP.NET. &amp;nbsp;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;NServiceBus.AllAssemblies&lt;/b&gt; - &amp;nbsp;This class allows you to provide a list of assemblies not to load. &amp;nbsp;An example of this would be "AllAssemblies.Except( "Assembly1" ).And("Assembly2")". &amp;nbsp;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;b&gt;.Synchronization()&lt;/b&gt; - tells NSB that message processing with occur in a synchronization domain. &amp;nbsp;This is useful for rich client applications where you need to marshal from a background thread back to the UI.&lt;/li&gt;&lt;li&gt;&lt;b&gt;.DefaultBuilder()&lt;/b&gt; or &lt;b&gt;.MyContainerOfChoiceBuilder()&lt;/b&gt; - this next set of methods controls the container. &amp;nbsp;You can take the default container(AutoFac as of 2.5) or specify your own. &amp;nbsp;You'll need to include the builder implementation for your container as well as specify an instance of your container. &amp;nbsp;&lt;/li&gt;&lt;li&gt;&lt;b&gt;.UnicastBus()&lt;/b&gt; - use unicast messaging&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;DoNotAutoSubscribe()&lt;/b&gt; - do not auto subscribe to a Publisher's messages&lt;/li&gt;&lt;li&gt;&lt;b&gt;ForwardReceivedMessagesTo( String )&lt;/b&gt; - forward all messages to another endpoint. &amp;nbsp;This is helpful if you want to do some auditing.&lt;/li&gt;&lt;li&gt;&lt;b&gt;LoadMessageHandlers()&lt;/b&gt;&amp;nbsp;- tells the bus to scan and load message handlers. &amp;nbsp;There are a couple interesting variants on this method:&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;LoadMessageHandlers&amp;lt;TFirst&amp;gt;&lt;/b&gt;&amp;nbsp;- tells the bus to load the handlers but load the assembly where TFirst resides before the rest&lt;/li&gt;&lt;li&gt;&lt;b&gt;LoadMessageHandlers&amp;lt;T&amp;gt;( First&amp;lt;T&amp;gt; )&lt;/b&gt;&amp;nbsp;- load the handlers and specifies that the handlers in the given order should go first. &amp;nbsp;To use the First class to specify ordering, it has 2 methods, "Then" and "AndThen". &amp;nbsp;A typical usages would be "First&amp;lt;IHandler1&amp;gt;.Then&amp;lt;IHandler2&amp;gt;().AndThen&amp;lt;IHandler3&amp;gt;()"&lt;/li&gt;&lt;li&gt;&lt;b&gt;PropagateReturnAddressOnSend( Boolean )&lt;/b&gt;&amp;nbsp;- receivers of the messages sent by this endpoint will see the address of the incoming messages&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;li&gt;&lt;b&gt;.XmlSerializer()&lt;/b&gt; or &lt;b&gt;.BinarySerializer()&lt;/b&gt; - specify the serialization technique you'd like to use.&lt;/li&gt;&lt;li&gt;&lt;b&gt;.CustomConfigurationSource( IConfigurationSource source )&lt;/b&gt; - if you would rather not use the standard app.config file or its sections for Administrative configuration, you are welcome to use your own. Simply implement the IConfigurationSource interface and you are on your way.&lt;/li&gt;&lt;li&gt;&lt;b&gt;.MsmqTransport()&lt;/b&gt; - tells NSB to use MSMQ as the underlying communication mechanism. &amp;nbsp;This may be swapped out in favor of other transports. &amp;nbsp;Along with this setting, you can configure a few things underneath it:&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;.DoNotCreateQueues()&lt;/b&gt; - don't try to create queues if they don't exist&lt;/li&gt;&lt;li&gt;&lt;b&gt;.IsolationLevel( IsolationLevel )&lt;/b&gt; - the isolation level of the transaction that MSMQ uses. &amp;nbsp;You may consider tweaking this for performance reasons or otherwise.&lt;/li&gt;&lt;li&gt;&lt;b&gt;.IsTransactional( Boolean )&lt;/b&gt; - for web scenarios, you may not want to use a transaction when pushing a message to the queue&lt;/li&gt;&lt;li&gt;&lt;b&gt;.PurgeOnStartup( Boolean )&lt;/b&gt; - determine whether or not to purge queues when NSB starts up.&lt;/li&gt;&lt;li&gt;&lt;b&gt;.TransactionTimeout( Timespan )&lt;/b&gt; - the time to wait for a transaction&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;b&gt;.MsmqSubscriptionStorage()&lt;/b&gt; or &lt;b&gt;DBSubscriptionStorage()&lt;/b&gt; - tells NSB where to persist subscriptions. &amp;nbsp;If you are using Profiles, this is set in the Profile of choice(Lite, Integration, or Production). &amp;nbsp;If using MSMQ, the queue to use is in the config file. &amp;nbsp;If &amp;nbsp;using NHibernate, you can default to the config file for NH properties or supply an IDictionary to the overload.&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;.DBSubscriptionStorageWithSQLLiteAndAutomaticSchemaGeneration()&lt;/b&gt; - pretty sure we all have this one down.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;b&gt;.Sagas()&lt;/b&gt; - tells NSB to look for Sagas in the assemblies provided to NSB in the&amp;nbsp;beginning&amp;nbsp;of the process.&lt;/li&gt;&lt;li&gt;&lt;b&gt;.NHibernateSagaPersister()&lt;/b&gt; - this will use NH for Saga persistence. &amp;nbsp;Unless supplied to the overload, NSB will use the config file for the NH properties. &amp;nbsp;You can give this method an IDictionary of properties as this point. &amp;nbsp;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;NHibernateSagaPersisterWithSQLLiteAndAutomaticSchemaGeneration()&lt;/b&gt; - pretty self explanatory I think.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;b&gt;.RijdaelEncryptionService()&lt;/b&gt; - if you are encrypting messages, this will load the keys from the config.&lt;/li&gt;&lt;li&gt;&lt;b&gt;.Log4Net()&lt;/b&gt; - there are a few overloads here for you to tweak Log4Net. &amp;nbsp;You have access to the Appender, AppenderSkeleton, and you and specify your own configuration.&lt;/li&gt;&lt;li&gt;&lt;b&gt;.RunCustomAction( Action )&lt;/b&gt; - this is a place where you can run anything you want really. &amp;nbsp;Typically I've seen this used to tweak the container very early in the boot strapping process.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;b&gt;New 3.0 Options&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;/b&gt;Some of the options have moved around to new classes, but the semantics remain the same. &amp;nbsp;Below are some of the new options available to address new features.&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;.MessageForwardingInCaseOfFault()&lt;/b&gt;&amp;nbsp;- tells the bus to forward messages when there is a fault&lt;/li&gt;&lt;li&gt;&lt;b&gt;.FtpTransport()&lt;/b&gt;&amp;nbsp;- FTP transport options&lt;/li&gt;&lt;li&gt;&lt;b&gt;.ImpersonateSender(Boolean)&lt;/b&gt;&amp;nbsp;- whether we should impersonate the sender or not&lt;/li&gt;&lt;li&gt;&lt;b&gt;.InMemoryFaultManagement()&lt;/b&gt;&amp;nbsp;- sets up the in memory fault manager. &amp;nbsp;Faults are lost when the process shuts down.&lt;/li&gt;&lt;li&gt;&lt;b&gt;.NHibernateFaultManager()&lt;/b&gt;&amp;nbsp;- sets up the NH fault manager. &amp;nbsp;Faults are saved to a database with the exception that caused them.&lt;/li&gt;&lt;li&gt;&lt;b&gt;.NHibernateUnitOfWork()&lt;/b&gt;&amp;nbsp;- sets the UOW manager to use the internal NSB NH manager. &amp;nbsp;You can supply your own if you are also using NH in your code.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;As we've found out, you have full control over how NSB is configured right from the start. &amp;nbsp;Next time we'll a close look at the Roles we talked about earlier in the article.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-4153506822140799596?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/4153506822140799596/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2011/03/nservicebus-customization-part-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/4153506822140799596'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/4153506822140799596'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2011/03/nservicebus-customization-part-1.html' title='NServiceBus Customization Part 1: IWantCustomInitialization'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-5843318803925239773</id><published>2011-03-21T11:56:00.000-07:00</published><updated>2011-03-21T11:56:37.160-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MSMQ'/><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><category scheme='http://www.blogger.com/atom/ns#' term='Powershell'/><title type='text'>ReturnToSourceQueue PowerShell Script: Updated</title><content type='html'>UPDATE: I've added transaction support to the script. &amp;nbsp;Previous to this you would have lost a message if something had gone wrong. &amp;nbsp;PS does not support TransactionScope, so we had to use MessageQueueTransaction.&lt;br /&gt;&lt;br /&gt;The ReturnToSourceQueue.exe tool that comes with NSB presented a challenge to us when we tried to deploy it on all our app servers. &amp;nbsp;We needed to schedule an on-demand job to run the tool by our Operations group. &amp;nbsp;Since the agent we use goes on each machine and is not cluster aware, this presented an issue. &amp;nbsp;Our resolution was to replicate the same functionality in PS with a bit of a twist. &amp;nbsp;We added the ability to hit a remote queue. &amp;nbsp;The script was done by one of our developers Brandon Moriarty and I've&amp;nbsp;&lt;a href="https://github.com/afyles/Blog/blob/master/PowerShell/ReturnToSourceQueue.ps1"&gt;posted it to GitHub&lt;/a&gt;&amp;nbsp;for everyone to enjoy! &amp;nbsp;Big thanks to Brandon for whipping this one up. &amp;nbsp;Don't forget I have a few other PS scripts in there to do some quick and dirty things with MSMQ.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-5843318803925239773?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/5843318803925239773/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2011/03/returntosourcequeue-powershell-script_21.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/5843318803925239773'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/5843318803925239773'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2011/03/returntosourcequeue-powershell-script_21.html' title='ReturnToSourceQueue PowerShell Script: Updated'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-4544695409516546943</id><published>2011-03-18T07:44:00.000-07:00</published><updated>2011-03-18T07:44:08.034-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><title type='text'>NServiceBus Customization, Let me Count the Ways!</title><content type='html'>So as promised I'm going to start a new series on customizing the behaviour of NSB.  I figured that we'd first try to count up all the ways to do it and then tackle each one by one.  I'm going to categorize them by when they occur during the NSB lifetime, Startup, Processing, and Shutdown. &amp;nbsp;I'm not going to include everything(it would take forever), but I'm going to include the most popular places where you'd customize.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Startup&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;IWantCustomInitialization - take over control of how the bus is initialized, skipping Roles&lt;/li&gt;&lt;li&gt;Roles - AsA_* interfaces.  Control how the bus is initialized.&lt;/li&gt;&lt;li&gt;IWantToRunAtStartup - run a custom action once at startup&lt;/li&gt;&lt;li&gt;IConfigureLoggingForProfile&amp;lt;T&amp;gt; - configure logging for a specific Profile&lt;/li&gt;&lt;li&gt;Profiles - IProfile.  Determine settings for a given target environment.  OOTB includes "Lite", "Integration", and "Production"&lt;/li&gt;&lt;li&gt;ISpecifyMessageOrderHandling - creates a "pipeline" of messages and gives them a specific order&lt;/li&gt;&lt;li&gt;The Container - you can pretty much change anything in the container, including passing in your own that is loaded with your stuff.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;b&gt;Processing&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;IMessageMutator - manipulate inbound and outbound messages&lt;/li&gt;&lt;li&gt;IMessageModule - inject some logic before and after message processing&lt;/li&gt;&lt;li&gt;IManageUnitsOfWork - UOW pattern handling&lt;/li&gt;&lt;li&gt;IManageMessageFailures - custom failed message handling&lt;/li&gt;&lt;li&gt;Processing Events - StartedMessageProcessing, TransportMessageReceived, FinishedMessageProcessing, FailedMessageProcessing. &amp;nbsp;You can use these to do something when message events are happening(say perf counters)&lt;/li&gt;&lt;/ul&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;Shutdown&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;IWantToRunAtStartup - there is a Stop method here that gets called once during shutdown&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-4544695409516546943?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/4544695409516546943/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2011/03/nservicebus-customization-let-me-count.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/4544695409516546943'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/4544695409516546943'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2011/03/nservicebus-customization-let-me-count.html' title='NServiceBus Customization, Let me Count the Ways!'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-1630478624295187620</id><published>2011-03-18T05:24:00.000-07:00</published><updated>2011-03-18T05:24:56.520-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MSMQ'/><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><category scheme='http://www.blogger.com/atom/ns#' term='Powershell'/><title type='text'>ReturnToSourceQueue PowerShell Script</title><content type='html'>The ReturnToSourceQueue.exe tool that comes with NSB presented a challenge to us when we tried to deploy it on all our app servers. &amp;nbsp;We needed to schedule an on-demand job to run the tool by our Operations group. &amp;nbsp;Since the agent we use goes on each machine and is not cluster aware, this presented an issue. &amp;nbsp;Our resolution was to replicate the same functionality in PS with a bit of a twist. &amp;nbsp;We added the ability to hit a remote queue. &amp;nbsp;The script was done by one of our developers Brandon Moriarty and I've &lt;a href="https://github.com/afyles/Blog/blob/master/PowerShell/ReturnToSourceQueue.ps1"&gt;posted it to GitHub&lt;/a&gt; for everyone to enjoy! &amp;nbsp;Big thanks to Brandon for whipping this one up. &amp;nbsp;Don't forget I have a few other PS scripts in there to do some quick and dirty things with MSMQ.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-1630478624295187620?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/1630478624295187620/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2011/03/returntosourcequeue-powershell-script.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/1630478624295187620'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/1630478624295187620'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2011/03/returntosourcequeue-powershell-script.html' title='ReturnToSourceQueue PowerShell Script'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-3951288330350237068</id><published>2011-03-07T14:11:00.001-08:00</published><updated>2011-03-07T14:12:13.498-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><category scheme='http://www.blogger.com/atom/ns#' term='Oracle AQS'/><title type='text'>Oracle AQS Transport Now on NServiceBus-Contrib</title><content type='html'>Source has been committed to the&lt;a href="https://github.com/nservicebus/nservicebus-contrib"&gt; v2.5 branch on GitHub&lt;/a&gt;.  I'll start work on the master(a.k.a. 3.0 version) shortly.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-3951288330350237068?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/3951288330350237068/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2011/03/oracle-aqs-transport-now-on-nservicebus.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/3951288330350237068'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/3951288330350237068'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2011/03/oracle-aqs-transport-now-on-nservicebus.html' title='Oracle AQS Transport Now on NServiceBus-Contrib'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-479203445182418035</id><published>2011-02-28T17:10:00.000-08:00</published><updated>2011-02-28T17:10:55.254-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><category scheme='http://www.blogger.com/atom/ns#' term='Oracle AQS'/><title type='text'>Oracle AQS Transport Complete &amp; the Next Article Series</title><content type='html'>This went together pretty quickly.  I have a local version tested and working from both directions.  I can push messages in from the database side via a stored procedure and also from the .NET world.  All that is left is to fork NServiceBus-Contrib and get the code into that solution structure and figure out how to build it.  It's using Ruby/rake which I've never used before, but the format seems simple enough.  &lt;br /&gt;&lt;br /&gt;After that work is done, it's back to getting the 3.0 branch to function.  I'll need to work on the serialization issues with the headers, hopefully that is not a big deal.  I'll be sure to include all the SQL scripts I used to setup and test the transport.&lt;br /&gt;&lt;br /&gt;During our implementation of NSB, we came across many times where we had to customize NSB to do various things.  I'm thinking the next series will be on all the ways you can customize and extend NSB.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-479203445182418035?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/479203445182418035/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2011/02/oracle-aqs-transport-complete-next.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/479203445182418035'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/479203445182418035'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2011/02/oracle-aqs-transport-complete-next.html' title='Oracle AQS Transport Complete &amp; the Next Article Series'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-8275046168001129871</id><published>2011-02-22T16:01:00.000-08:00</published><updated>2011-02-22T16:01:38.538-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><category scheme='http://www.blogger.com/atom/ns#' term='Oracle AQS'/><title type='text'>Working on Oracle AQS Transport</title><content type='html'>Internally we have a need to hook into certain changes within some data that is housed in Oracle.  Our solution will be to use Oracle CDC(Change Data Capture) to grab the info we need right from the redo logs and push that data into a table.  We're going use the table to provide those who would like to do ETL a simple way to grab data that is not on the live tables and only contains the changes.  From this table we'll push the rows into Oracle AQ(Advanced Queuing).  From here we have the opportunity to drive that data right onto NSB much like the Service Broker is being used in &lt;a href="http://andreasohlund.net/2010/09/03/event-based-interop-with-service-broker/"&gt;this article&lt;/a&gt;.  &lt;br /&gt;&lt;br /&gt;Thanks to the contributors over at &lt;a href="https://github.com/nservicebus/nservicebus-contrib"&gt;NServiceBus/NServiceBus-Contrib&lt;/a&gt; I have a great head start.  I started out going down the NSB 3.0 route since the barrier to entry has been lowered greatly when attempting to create a custom Transport.  Inadvertently I realized that I'm going to need to support NSB 2.5 seeing as how most of my shop is still on 2.0 and moving to 2.5, not only that 3.0 is still considered alpha or pre-alpha even.  I also ran into an interesting serialization error in 3.0 anyway, once which I'll have to revisit later.  The message headers on TransportMessage in 3.0 is now a Dictionary(used to be a List) which the serializer does not like one bit.&lt;br /&gt;&lt;br /&gt;Luckily I was able to re-use the code from the 3.0 implementation.  Going back to the 2.5 methodology has been a bit painful, and I'm glad that the custom Transport story is changing drastically.  I have everything all set up and I'm ready to test.  I'm even running Oracle 10g Express locally so this thing should be easy to try out for everyone.  I'm interested to see if I can clean up some of the serialization work from the Service Broker implementation.  Oracle AQ  stores everything in a special table that backs the queue.  You can tell it to make the column that stores the data to be an XMLType column or RAW, which I'm hoping plays more nicely with the serializers.  &lt;br /&gt;&lt;br /&gt;Once I get something more solid my plan is to put the code out on my personal repository in github and then work on getting it integrated into NServiceBus-Contrib.  Let me know if anyone has already built this or is trying to, I'm always on the lookout for any problems or suggestions that have come up.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-8275046168001129871?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/8275046168001129871/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2011/02/working-on-oracle-aqs-transport.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/8275046168001129871'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/8275046168001129871'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2011/02/working-on-oracle-aqs-transport.html' title='Working on Oracle AQS Transport'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-1810816709435630429</id><published>2011-02-07T04:49:00.000-08:00</published><updated>2011-02-07T04:49:09.319-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><title type='text'>NServiceBus 3.0: Message Mutators</title><content type='html'>In NSB 2 it was a bit more tricky to change messages as they were sent to and from endpoints. &amp;nbsp;In NSB 3 we now have a couple of simple interfaces to plug in our custom logic to change messages. &amp;nbsp;The typical scenario this is used for is to encrypt all or part of a message. &amp;nbsp;The encryption message mutator is built right in and can be used at any time. &amp;nbsp;In this article we'll show how to create a custom message mutator to simply do some math on Double fields in a message. &amp;nbsp;Let's first take a quick look at the interfaces involved.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_sC2VEzP-9qE/TU_n2_i23XI/AAAAAAAAA30/-l9KmJqsXd4/s1600/nservice_bus_message_mutators.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="328" src="http://4.bp.blogspot.com/_sC2VEzP-9qE/TU_n2_i23XI/AAAAAAAAA30/-l9KmJqsXd4/s640/nservice_bus_message_mutators.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;Each interface gives us access to the message so that we can mutate on the inbound and/or outbound message. &amp;nbsp;All we have to do as a consumer is implement the desired interface and load it into the NSB container. &amp;nbsp;For my mutator, I will implement IMessageMutator and only implement the outgoing message for the time being.&lt;br /&gt;&lt;pre class="brush:c#"&gt;public class MultiplierMutator : IMessageMutator&lt;br /&gt;    {&lt;br /&gt;        #region IMutateOutgoingMessages Members&lt;br /&gt;&lt;br /&gt;        public NServiceBus.IMessage MutateOutgoing(NServiceBus.IMessage message)&lt;br /&gt;        {&lt;br /&gt;            var doubles = message.GetType().GetProperties().Where(p =&amp;gt; typeof(double).IsAssignableFrom(p.PropertyType));&lt;br /&gt;&lt;br /&gt;            foreach (var dbl in doubles)&lt;br /&gt;            {&lt;br /&gt;                double dblValue = (double)dbl.GetValue(message, null);&lt;br /&gt;                dbl.SetValue(message, dblValue * 5, null);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            return message;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        #endregion&lt;br /&gt;&lt;br /&gt;        #region IMutateIncomingMessages Members&lt;br /&gt;&lt;br /&gt;        public NServiceBus.IMessage MutateIncoming(NServiceBus.IMessage message)&lt;br /&gt;        {&lt;br /&gt;            return message;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        #endregion&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;In this class we first find all Double fields.  Once we have that list we simply multiply each field by an arbitrary number, in this case 5.  The last thing we need to do is let the container know about the mutator.  We do this in our implementation of IWantCustomInitialization.&lt;br /&gt;&lt;pre class="brush:c#"&gt;NServiceBus.Configure.Instance.Configurer.ConfigureComponent&amp;lt;MultiplierMutator&amp;gt;(NServiceBus.ObjectBuilder.DependencyLifecycle.InstancePerCall);&lt;br /&gt;&lt;/pre&gt;Now we can fire up our endpoints and watch what happens.  I stubbed this into the Encryption sample that comes with the NSB download.  In the Client project I added a value to the Result field on the message.&lt;br /&gt;&lt;pre class="brush:c#"&gt;while (Console.ReadLine() != null)&lt;br /&gt;            {&lt;br /&gt;                Bus.Send&amp;lt;MessageWithSecretData&amp;gt;(m =&amp;gt;&lt;br /&gt;                    {&lt;br /&gt;                        m.Secret = "betcha can't guess my secret";&lt;br /&gt;                        m.Result = 5;&lt;br /&gt;                    });&lt;br /&gt;            }&lt;br /&gt;&lt;/pre&gt;Now for the output from the Server project:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_sC2VEzP-9qE/TU_p2eZNiuI/AAAAAAAAA34/KIN9bUxisnw/s1600/nservice_bus_message_mutator_output.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="93" src="http://4.bp.blogspot.com/_sC2VEzP-9qE/TU_p2eZNiuI/AAAAAAAAA34/KIN9bUxisnw/s400/nservice_bus_message_mutator_output.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;So that's it!  Now we can dream up any kind of change to our messages.  Maybe you want to compress or hash some of the messages, it's all up to you.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-1810816709435630429?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/1810816709435630429/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2011/02/nservicebus-30-message-mutators.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/1810816709435630429'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/1810816709435630429'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2011/02/nservicebus-30-message-mutators.html' title='NServiceBus 3.0: Message Mutators'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_sC2VEzP-9qE/TU_n2_i23XI/AAAAAAAAA30/-l9KmJqsXd4/s72-c/nservice_bus_message_mutators.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-2544472319860313983</id><published>2011-01-26T14:07:00.000-08:00</published><updated>2011-01-26T14:07:22.115-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MSMQ'/><title type='text'>MSMQ PowerShell Scripts</title><content type='html'>I thought I'd hand out a couple of PowerShell scripts that I whipped up for our Server Admin friends. &amp;nbsp;You can use these to do some basic things with MSMQ such as send a message, browse messages in a queue, and return messages to a source queue. &amp;nbsp;Check them out:&amp;nbsp;&lt;a href="https://github.com/afyles/Blog/tree/master/PowerShell"&gt;https://github.com/afyles/Blog/tree/master/PowerShell&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-2544472319860313983?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/2544472319860313983/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2011/01/msmq-powershell-scripts.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/2544472319860313983'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/2544472319860313983'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2011/01/msmq-powershell-scripts.html' title='MSMQ PowerShell Scripts'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-4351845868315826763</id><published>2011-01-24T07:40:00.000-08:00</published><updated>2011-01-24T07:40:15.075-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><category scheme='http://www.blogger.com/atom/ns#' term='MSDTC'/><title type='text'>Clustered MSDTC Mutual Authentication Gotcha Between 2003/2008 Servers</title><content type='html'>This is more of a mental note that anything else, but we ran across an issue with configuring our subscriptions database on a cluster. &amp;nbsp;What we had set up was a 2008 cluster with our Publisher on it and a 2003 cluster with our subscriptions DB on it. &amp;nbsp;MSTC was giving us a very distinct error:&lt;br /&gt;&lt;br /&gt;[SQL: SELECT this_.SubscriberEndpoint as y0_ FROM [Subscription] this_ WHERE this_.MessageType in (?, ?, ?)]; Communication with the underlying transaction manager has failed.; The MSDTC transaction manager was unable to push the transaction to the destination transaction manager due to communication problems. Possible causes are: a firewall is present and it doesn't have an exception for the MSDTC process, the two machines cannot find each other by their NetBIOS names, or the support for network transactions is not enabled for one of the two transaction managers. (Exception from HRESULT: 0x8004D02A)&lt;br /&gt;&lt;br /&gt;The solution for this was that 2003 servers in &lt;a href="http://support.microsoft.com/kb/899191"&gt;cluster doesn't support Mutual Authentication&lt;/a&gt;. &amp;nbsp;We ended up just using the Incoming Caller authentication between the clusters and everything started working again. &amp;nbsp;Hope this helps someone else with the same problem.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-4351845868315826763?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/4351845868315826763/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2011/01/clustered-msdtc-mutual-authentication.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/4351845868315826763'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/4351845868315826763'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2011/01/clustered-msdtc-mutual-authentication.html' title='Clustered MSDTC Mutual Authentication Gotcha Between 2003/2008 Servers'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-700894098416544939</id><published>2011-01-16T12:06:00.000-08:00</published><updated>2011-01-16T12:06:02.600-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><title type='text'>NServiceBus 3.0: Alternative Transports</title><content type='html'>Back in NSB 2.0 you could create your own transport but it took a bit of work. &amp;nbsp;In 3.0 the concept has been better abstracted to allow us to write custom transports more easily. &amp;nbsp;What was introduced was a new set of interfaces for us to implement:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_sC2VEzP-9qE/TTNNB1-xDjI/AAAAAAAAA3k/W5hd5-Ps2Pw/s1600/nsb_queue_transport.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="225" src="http://4.bp.blogspot.com/_sC2VEzP-9qE/TTNNB1-xDjI/AAAAAAAAA3k/W5hd5-Ps2Pw/s400/nsb_queue_transport.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;These simple interfaces have been plugged into the transport layer and makes it pretty painless to derive a new transport. &amp;nbsp;In &amp;nbsp;NSB 3.0, we already have an FTP transport and an Azure transport. &amp;nbsp;I'm going to run through the FTP sample. &amp;nbsp;First things first, you have to setup a couple of FTP sites on your machine. &amp;nbsp;I followed the directions &lt;a href="http://serverfault.com/questions/85027/how-do-i-setup-an-ftp-server-on-windows-7"&gt;here&lt;/a&gt;. &amp;nbsp;To get the sample to work you have to set up one on port 1090 and one on port 1091.&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;Next we need to mod the config to match our local one, here is how my config looked for the Client:&lt;/div&gt;&lt;pre class="brush:xml"&gt;&lt;ftpqueueconfig password="blah" receivedirectory="d:\ftpclient" senddirectory="d:\ftpclient" username="anonymous"&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;unicastbusconfig distributorcontroladdress="" distributordataaddress="" localaddress="localhost:1090"&gt;&lt;br /&gt;    &lt;messageendpointmappings&gt;&lt;br /&gt;      &lt;add endpoint="localhost:1091" messages="TestMessage.FtpMessage, TestMessage"&gt;&lt;br /&gt;      &lt;add endpoint="TimeoutManager" messages="NServiceBus.Saga.TimeoutMessage, NServiceBus"&gt;&lt;br /&gt;    &lt;/add&gt;&lt;/add&gt;&lt;/messageendpointmappings&gt;&lt;br /&gt;  &lt;/unicastbusconfig&gt;&lt;br /&gt;&lt;/ftpqueueconfig&gt;&lt;/pre&gt;Here is the config for the Server:&lt;br /&gt;&lt;pre class="brush:xml"&gt;&lt;ftpqueueconfig password="blah" receivedirectory="d:\ftpserver" senddirectory="d:\ftpserver" username="anonymous"&gt;&lt;br /&gt;&lt;br /&gt;  &lt;msmqtransportconfig errorqueue="localhost:1091" inputqueue="localhost:1091" maxretries="2" numberofworkerthreads="1"&gt;&lt;br /&gt;&lt;br /&gt;  &lt;unicastbusconfig distributorcontroladdress="" distributordataaddress=""&gt;&lt;br /&gt;    &lt;messageendpointmappings&gt;&lt;br /&gt;      &lt;add endpoint="TimeoutManager" messages="NServiceBus.Saga.TimeoutMessage, NServiceBus"&gt;&lt;br /&gt;    &lt;/add&gt;&lt;/messageendpointmappings&gt;&lt;br /&gt;  &lt;/unicastbusconfig&gt;  &lt;br /&gt;&lt;/msmqtransportconfig&gt;&lt;/ftpqueueconfig&gt;&lt;/pre&gt;Now we can fire the whole thing up and start sending messages.  Once a message is sent you can see it in your FTP directory.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_sC2VEzP-9qE/TTNPJRnp99I/AAAAAAAAA3o/nmJis15k1uQ/s1600/nsb_ftp_content.png" imageanchor="1"&gt;&lt;img border="0" height="177" src="http://4.bp.blogspot.com/_sC2VEzP-9qE/TTNPJRnp99I/AAAAAAAAA3o/nmJis15k1uQ/s400/nsb_ftp_content.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Each is a file with the serialized data. &amp;nbsp;Its as simple as that! &amp;nbsp;It will be interesting to see what kind of other transports people plug in. &amp;nbsp;I'm hoping that there will be some other queue based transports like MQ Series.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-700894098416544939?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/700894098416544939/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2011/01/nservicebus-30-alternative-transports.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/700894098416544939'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/700894098416544939'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2011/01/nservicebus-30-alternative-transports.html' title='NServiceBus 3.0: Alternative Transports'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_sC2VEzP-9qE/TTNNB1-xDjI/AAAAAAAAA3k/W5hd5-Ps2Pw/s72-c/nsb_queue_transport.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-3752467306626746681</id><published>2011-01-04T16:09:00.000-08:00</published><updated>2011-01-04T16:11:06.547-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><title type='text'>NServiceBus 3.0: Fault Management</title><content type='html'>In NSB 3.0 we get some better support for message faults.  Prior to 3.0 we were able to capture messages that faulted after a configurable number of retries.  The difficulty with this is that since the actual exception was not captured with the fault, we as developers weren't able to do to much with that message besides blindly replay the message.  In 3.0 this all changes in that there is a dedicated set of classes for fault management.  Below is a class diagram of the hierarchy.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOwO61n2_I/AAAAAAAAA3U/wdWCvmGgYwg/s1600/nsb_faults_class_diagram.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="400" src="http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOwO61n2_I/AAAAAAAAA3U/wdWCvmGgYwg/s640/nsb_faults_class_diagram.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Out of the box we get 3 ways to manage faults. &amp;nbsp;The Forwarder simply does what NSB has done in the past, which is move the message to a designated queue. &amp;nbsp;The InMemory manager simply holds the message in memory for the lifetime of the host process. &amp;nbsp;Lastly, the NHibernate Fault Manager allows us to store the message along with the exception that caused it to be faulted. &amp;nbsp;This allows us to be smarter about how we handle faults. &lt;br /&gt;&lt;br /&gt;To follow along you will need to download the 3.0 branch from GitHub and build it. &amp;nbsp;From there open up the "FaultHandling" sample. &amp;nbsp;When I downloaded this sample, it did not work right away. &amp;nbsp;If you fire up the solution, nothing really happens. &amp;nbsp; First and foremost you have to change the MyClient project endpoint to be transactional. &amp;nbsp;If it is not, the fault management gets skipped right over in code.  Simply edit the EndpointConfig.cs file to configure it AsA_Server.&lt;br /&gt;&lt;pre class="brush:c#"&gt;public class EndpointConfig : IConfigureThisEndpoint, AsA_Server {}&lt;br /&gt;&lt;/pre&gt;The next issue I ran into is that the default profile(Lite) gives us the InMemory Fault Manager.  The sample configured this via the IWantCustomInitialization insertion point.  The only way I managed to get this to work was to move it to a custom profile, aptly named "Custom"&lt;br /&gt;&lt;pre class="brush:c#"&gt;class Custom : IProfile{}&lt;br /&gt;&lt;br /&gt;  class CustomProfile : IHandleProfile&amp;lt;Custom&amp;gt;&lt;br /&gt;  {&lt;br /&gt;        #region IHandleProfile Members&lt;br /&gt;&lt;br /&gt;        public void ProfileActivated()&lt;br /&gt;        {&lt;br /&gt;            Configure.Instance.InMemorySagaPersister();&lt;br /&gt;            Configure.Instance.NHibernateFaultManagerWithSQLiteAndAutomaticSchemaGeneration();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        #endregion&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt;&lt;/pre&gt;Now that we have everything configured appropriately we can run MyClient.  After launching the solution, simply enter an "s" to send a few messages.  Sooner or later one of them will fail and start the retry cycle.  Once that is complete, the NH Fault Manager kicks in and pushes the messages to SQLLite in my case.  Here is what the output looks like:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_sC2VEzP-9qE/TSO1ktRRE4I/AAAAAAAAA3c/BqIiLvxHnp8/s1600/nsb_faults_output.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="230" src="http://1.bp.blogspot.com/_sC2VEzP-9qE/TSO1ktRRE4I/AAAAAAAAA3c/BqIiLvxHnp8/s400/nsb_faults_output.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;Next we can dive to SQLLite to see what the output looks like. &amp;nbsp;Note that the Message column hasn't been populated, but I'm hoping this simply a SQLLite issue. &lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_sC2VEzP-9qE/TSO2QrgeTpI/AAAAAAAAA3g/oiqM0Ti-lKk/s1600/nsb_faults_sqllite.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="326" src="http://4.bp.blogspot.com/_sC2VEzP-9qE/TSO2QrgeTpI/AAAAAAAAA3g/oiqM0Ti-lKk/s640/nsb_faults_sqllite.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;From here we can now make better decisions on what to do with these faulted messages. &amp;nbsp;I'm going to try using a full fledged SQL Server instance to see if the "Message" column gets populated. &amp;nbsp;If not, looks like I'll be reporting a bug.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-3752467306626746681?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/3752467306626746681/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2011/01/nservicebus-30-fault-management.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/3752467306626746681'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/3752467306626746681'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2011/01/nservicebus-30-fault-management.html' title='NServiceBus 3.0: Fault Management'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOwO61n2_I/AAAAAAAAA3U/wdWCvmGgYwg/s72-c/nsb_faults_class_diagram.png' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-5711979371810013337</id><published>2011-01-03T11:19:00.000-08:00</published><updated>2011-01-03T11:19:42.802-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><title type='text'>NServiceBus 2.5 Gets Official</title><content type='html'>NSB 2.5 is here!! It's mainly a lot of bug fixes.  The most important one for us will be the bug fix for a Worker node to continue processing after a message failure.  In 2.0, the Worker would take itself out of the loop after the failure and you'd have to restart it.  Now in 2.5 it will continue processing.&lt;br /&gt;&lt;br /&gt;I know I still owe the community some articles on 3.0.  I've been busy upgrading to TFS 2010 here at work.  The other thing is that I've been unable to get a full sample going for the Fault Management feature.  I'm stuck on one final piece, which is getting SQLLite/NHibernate to work.  Oddly, the transactions are committed and I can see data in SQLLite(the file), but I can't get anything when I query it.  I'm hoping to solve that soon.  If anyone has any ideas, let me know.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-5711979371810013337?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/5711979371810013337/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2011/01/nservicebus-25-gets-official.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/5711979371810013337'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/5711979371810013337'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2011/01/nservicebus-25-gets-official.html' title='NServiceBus 2.5 Gets Official'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-7906968340271747228</id><published>2010-12-15T06:47:00.001-08:00</published><updated>2010-12-15T06:47:00.642-08:00</updated><title type='text'>VDUNY Slidedeck: Introduction to NServiceBus</title><content type='html'>Here are the slides I delivered for the VDUNY group, it was a lot of fun and thanks again to all who showed up despite the bad weather.&lt;div style="width:425px" id="__ss_6176415"&gt;&lt;strong style="display:block;margin:12px 0 4px"&gt;&lt;a href="http://www.slideshare.net/afyles/introduction-to-nservicebus" title="Introduction to NServiceBus"&gt;Introduction to NServiceBus&lt;/a&gt;&lt;/strong&gt;&lt;object id="__sse6176415" width="425" height="355"&gt;&lt;param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=introductiontonservicebus-101215083415-phpapp01&amp;stripped_title=introduction-to-nservicebus&amp;userName=afyles" /&gt;&lt;param name="allowFullScreen" value="true"/&gt;&lt;param name="allowScriptAccess" value="always"/&gt;&lt;embed name="__sse6176415" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=introductiontonservicebus-101215083415-phpapp01&amp;stripped_title=introduction-to-nservicebus&amp;userName=afyles" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div style="padding:5px 0 12px"&gt;View more &lt;a href="http://www.slideshare.net/"&gt;presentations&lt;/a&gt; from &lt;a href="http://www.slideshare.net/afyles"&gt;afyles&lt;/a&gt;.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-7906968340271747228?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/7906968340271747228/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2010/12/vduny-slidedeck-introduction-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/7906968340271747228'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/7906968340271747228'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2010/12/vduny-slidedeck-introduction-to.html' title='VDUNY Slidedeck: Introduction to NServiceBus'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-4134123433654812947</id><published>2010-12-09T05:42:00.000-08:00</published><updated>2010-12-09T05:42:43.128-08:00</updated><title type='text'>VDUNY Intro to NServiceBus Talk December 14th</title><content type='html'>I'll be giving an introduction to NSB for the Visual Developers of Upstate New York this month.  You can find the details here: &lt;a href="http://www.vduny.org/futmeet.asp"&gt;http://www.vduny.org/futmeet.asp&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-4134123433654812947?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/4134123433654812947/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2010/12/vduny-intro-to-nservicebus-talk.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/4134123433654812947'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/4134123433654812947'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2010/12/vduny-intro-to-nservicebus-talk.html' title='VDUNY Intro to NServiceBus Talk December 14th'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-179013387340585389</id><published>2010-11-28T09:26:00.000-08:00</published><updated>2010-11-28T09:26:29.697-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><title type='text'>New Series Announcement: NServiceBus 3.0</title><content type='html'>My apologies for the long hiatus, I was trying to figure out where to go next after doing the "Getting Started" series.  I think I've pretty much gotten through the basics with NServiceBus.  After posting on SO and not getting an answer as to what the new features will be in NSB 3.0, I decided I'll take the time to dissect it myself.  I guess I had forgotten this is a very DIY framework so I'll do my best to "discover" the new features.  So my next post will be the first in a series about NSB 3.  See you soon!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-179013387340585389?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/179013387340585389/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2010/11/new-series-announcement-nservicebus-30.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/179013387340585389'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/179013387340585389'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2010/11/new-series-announcement-nservicebus-30.html' title='New Series Announcement: NServiceBus 3.0'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-4190538371730269235</id><published>2010-11-07T14:15:00.000-08:00</published><updated>2010-11-07T14:18:21.448-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><category scheme='http://www.blogger.com/atom/ns#' term='Scaling'/><title type='text'>Getting Started with NServiceBus Part 9: Horizontal Scaling with the Distributor</title><content type='html'>A single thread NServiceBus instance can handle quite of bit of messages.  We're talking around 30 messages/second or roughly 2.5 million messages a day.  It may be the case that if you need more throughput you can ramp up the number of threads NSB uses.  If you would rather not do that and keep it single threaded but still scale out you can do so with the built-in Distributor process. &amp;nbsp;Check out the first slide at the end of the post for the general message flow.&lt;br /&gt;&lt;br /&gt;Fundamentally the Distributor is comprised of at least 3 processes.  The first is the Distributor process itself which holds onto the entire set of work that the Workers will operate upon.  The reason the Distributor holds the work is so that if one of the Workers goes down, it can shift that work over to the other Worker(s).  The other 2 processes are Worker processes that do the actual work and also report their status back to the Distributor.  At its core the Distributor receives work from some other process and then dishes out the work based on the current status of the Workers.  &lt;br /&gt;&lt;br /&gt;The workflow is controlled by a few internal queues to the Distributor itself.  The Distributor has a Control, Storage, and Data(work) queue.  The Control queue is where the Workers will put their Ready messages.  The Storage queue keeps track of the addresses of the Workers and is used to determine which Worker is available next for work.  The Data queue keeps the set of work.  All of these settings are kept in the app.config of the Distributor process.&lt;br /&gt;&lt;pre class="brush:xml"&gt;&lt;appsettings&gt;&lt;br /&gt;    &lt;add key="NumberOfWorkerThreads" value="1"&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;add key="DataInputQueue" value="nservicebus_distributor_data_bus"&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;add key="ControlInputQueue" value="nservicebus_distributor_control_bus"&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;add key="ErrorQueue" value="nservicebus_error"&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;add key="StorageQueue" value="nservicebus_distributor_storage"&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;add key="NameSpace" value="http://www.mysite.com"&gt; &lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;    &lt;add key="Serialization" value="xml"&gt;&lt;br /&gt;    &lt;br /&gt;&lt;/add&gt;&lt;/add&gt;&lt;/add&gt;&lt;/add&gt;&lt;/add&gt;&lt;/add&gt;&lt;/add&gt;&lt;/appsettings&gt;&lt;/pre&gt;Once the Distributor is configured we must tell each Worker how to communicate with the Distributor.&lt;br /&gt;&lt;pre class="brush:xml"&gt;&lt;unicastbusconfig distributorcontroladdress="nservicebus_distributor_control_bus" distributordataaddress="nservicebus_distributor_data_bus"&gt;&lt;br /&gt;    &lt;messageendpointmappings&gt;&lt;br /&gt;    &lt;/messageendpointmappings&gt;&lt;br /&gt;  &lt;/unicastbusconfig&gt;&lt;br /&gt;&lt;/pre&gt;Once we have everything configured the workflow is a multi-step process that goes like this:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;A Worker starts up and places a Ready message on the Distributor's Control queue. &amp;nbsp;This message is read and pushes a message on the Storage queue to indicate that we have an available Worker.&lt;/li&gt;&lt;li&gt;Step 1 is repeated for all Worker that start up.&lt;/li&gt;&lt;li&gt;A Client issuing the work sends a message to the Data queue.&lt;/li&gt;&lt;li&gt;The message is read from the Data queue and the Distributor pops the next available Worker from the Storage queue&lt;/li&gt;&lt;li&gt;The message is then forwarded to the Worker and the Worker handles the message.&lt;/li&gt;&lt;li&gt;Once the Worker is done it sends a Ready message back to the Control queue to signify that it is ready for more work.&lt;/li&gt;&lt;li&gt;If the first Worker is still working as more work comes in, the next available Worker gets the next message. &amp;nbsp;If all Workers are busy, then the Distributor queues up the messages in the Data queue.&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;Check out the second slide in the deck at the end of the post to have a visual of the flow.&lt;br /&gt;&lt;br /&gt;The Worker message Handlers are written just like any old NSB handler. &amp;nbsp;The only other missing component is that you will need to send the Distributor some work. &amp;nbsp;When you fire up all the processes you can send messages to the Distributor and watch the work load balance. &amp;nbsp;Since the Distributor holds all the work you may want to make the Distributor highly available and put it into a cluster.&lt;br /&gt;&lt;br /&gt;I have a full working sample on github: &lt;a href="https://github.com/afyles/Blog/tree/master/NServiceBusExplorer/"&gt;https://github.com/afyles/Blog/tree/master/NServiceBusExplorer/&lt;/a&gt;.  All you need to do is fire up the Distributor and the 2 Workers in the Workers folder under the Source directory.&lt;br /&gt;&lt;br /&gt;&lt;div style="width:425px" id="__ss_5696625"&gt;&lt;strong style="display:block;margin:12px 0 4px"&gt;&lt;a href="http://www.slideshare.net/afyles/nservicebus-distributor" title="NServiceBus Distributor"&gt;NServiceBus Distributor&lt;/a&gt;&lt;/strong&gt;&lt;object id="__sse5696625" width="425" height="355"&gt;&lt;param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=nservicebusdistributor-101107155113-phpapp01&amp;stripped_title=nservicebus-distributor&amp;userName=afyles" /&gt;&lt;param name="allowFullScreen" value="true"/&gt;&lt;param name="allowScriptAccess" value="always"/&gt;&lt;embed name="__sse5696625" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=nservicebusdistributor-101107155113-phpapp01&amp;stripped_title=nservicebus-distributor&amp;userName=afyles" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div style="padding:5px 0 12px"&gt;View more &lt;a href="http://www.slideshare.net/"&gt;presentations&lt;/a&gt; from &lt;a href="http://www.slideshare.net/afyles"&gt;afyles&lt;/a&gt;.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-4190538371730269235?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/4190538371730269235/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2010/11/getting-started-with-nservicebus-part-9.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/4190538371730269235'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/4190538371730269235'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2010/11/getting-started-with-nservicebus-part-9.html' title='Getting Started with NServiceBus Part 9: Horizontal Scaling with the Distributor'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-7334606797643271257</id><published>2010-11-04T11:51:00.000-07:00</published><updated>2010-11-04T11:51:14.310-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Powershell'/><title type='text'>Powershell: Reading Messages from MSMQ</title><content type='html'>I'm throwing this out there since I couldn't find anything good online.  We have admins that need to quickly look at messages in queues and the built-in tooling just isn't pretty to look at.  Slap this PS code into a script file and you should be ready to rock!&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;param([string]$qname)&lt;br /&gt;&lt;br /&gt;if ( [System.String]::IsNullOrEmpty($qname) )&lt;br /&gt;{&lt;br /&gt;    write-host "You must provide a queue name"&lt;br /&gt;    exit&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;[Reflection.Assembly]::LoadWithPartialName("System.Messaging") | out-null&lt;br /&gt;&lt;br /&gt;$q = new-object System.Messaging.MessageQueue($qname)&lt;br /&gt;&lt;br /&gt;$msgs = $q.GetAllMessages()&lt;br /&gt;&lt;br /&gt;foreach ( $msg in $msgs )&lt;br /&gt;{&lt;br /&gt;    $msg.BodyStream.Position = 0&lt;br /&gt;    $sr = new-object System.IO.StreamReader( $msg.BodyStream )&lt;br /&gt;    $sr.ReadToEnd()&lt;br /&gt;    $input = read-host -prompt "Enter n for the next message, q to quit"&lt;br /&gt;    &lt;br /&gt;    if ( $input -eq "q" )&lt;br /&gt;    {&lt;br /&gt;        exit&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-7334606797643271257?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/7334606797643271257/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2010/11/powershell-reading-messages-from-msmq.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/7334606797643271257'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/7334606797643271257'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2010/11/powershell-reading-messages-from-msmq.html' title='Powershell: Reading Messages from MSMQ'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-8198973376442062319</id><published>2010-11-01T07:40:00.000-07:00</published><updated>2010-11-01T10:13:35.782-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><title type='text'>Getting Started with NServiceBus Part 8: Message Versioning</title><content type='html'>So now you've gone live with your first system based on NSB.  Time goes by and you have a new requirement to add some data to a published event.  How will we provide backwards compatibility?  How will we upgrade?  What if legacy subscribers don't care about the new information?  Luckily for us NSB handles this given we modeled our messages as interfaces, giving us an inheritance structure we can use to our advantage.  This article will how how easily this can be done.  &lt;br /&gt;&lt;br /&gt;Let's begin given our current message:&lt;br /&gt;&lt;pre class="brush:c#"&gt;public interface IProductUpdatedEvent : IProductChangedEvent&lt;br /&gt;    {&lt;br /&gt;    }&lt;br /&gt;    public interface IProductChangedEvent : IEvent&lt;br /&gt;    {&lt;br /&gt;        Int32 ProductNumber { get; set; }&lt;br /&gt;        String Name { get; set; }&lt;br /&gt;        String Description { get; set; }       &lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;Now let's say we want to add a new field to our event.  We create the new event in a different namespace so we can use the same interface name and add our new field after we implement the old interface:&lt;br /&gt;&lt;pre class="brush:c#"&gt;public interface IProductUpdatedEvent : Messages.IProductUpdatedEvent&lt;br /&gt;    {&lt;br /&gt;        Int32 DepartmentNumber { get; set; }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;So now we have two distinct messages that have different data sets.  This means our legacy clients can continue to receive the legacy message and our new clients can receive the new message.  Here is an example of a handler pointing to the new message type:&lt;br /&gt;&lt;pre class="brush:c#"&gt;public class EventMessageHandler : IMessageHandler&amp;lt;Messages.New.IProductUpdatedEvent&amp;gt;&lt;br /&gt;    {&lt;br /&gt;        private static ILog log = LogManager.GetLogger(typeof(EventMessageHandler));&lt;br /&gt;&lt;br /&gt;        public void Handle(Messages.New.IProductUpdatedEvent message)&lt;br /&gt;        {&lt;br /&gt;            log.Debug(String.Format("{0} Event Received for Product {1}: {2} : {3}", message.GetType().UnderlyingSystemType.Name, message.ProductNumber, message.Name, message.DepartmentNumber));&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;The rest of our Subscribers remain the same.  All that is left is to update the Publisher to publish the new event.  In the example code there is a Windows Forms app(UI) that pushes all events to a common Publisher endpoint.  See the Documentation directory for a diagram.  In the example all we have to do is add the new field and publish the new event.&lt;br /&gt;&lt;pre class="brush:c#"&gt;Messages.New.IProductUpdatedEvent pu = new Messages.New.ProductUpdatedMessage&lt;br /&gt;            {&lt;br /&gt;                ProductNumber = Int32.Parse(textBoxUpdateID.Text),&lt;br /&gt;                Description = textBoxUpdateDesc.Text,&lt;br /&gt;                Name = textBoxUpdateName.Text,&lt;br /&gt;                EventId = Guid.NewGuid(),&lt;br /&gt;                Time = DateTime.Now,                &lt;br /&gt;                DepartmentNumber = 10&lt;br /&gt;            };&lt;br /&gt;&lt;br /&gt;            FireEvent(pu);&lt;br /&gt;&lt;/pre&gt;If you pull down the sample and look in the PubSub directory, fire up the BusServer, UI, Subscriber1, and Subscriber3 projects.  From the UI simple type in second group box and hit the "Update" button.  This will send the new message to the "BusServer" Publisher endpoint which will do the actual Bus.Publish().  From there you will see Subscriber1 receive the legacy event and Subscriber3 receive the new event with the new data.  &lt;br /&gt;&lt;br /&gt;NSB allows us to gracefully support new message types and uphold backwards compatibility.  We were able to introduce new data and rely upon inheritance to handle the rest.  Full code can be found here: http://github.com/afyles/Blog/tree/master/NServiceBusExplorer/&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-8198973376442062319?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/8198973376442062319/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2010/11/getting-started-with-nservicebus-part-8.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/8198973376442062319'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/8198973376442062319'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2010/11/getting-started-with-nservicebus-part-8.html' title='Getting Started with NServiceBus Part 8: Message Versioning'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-7545967597053314914</id><published>2010-10-18T10:19:00.001-07:00</published><updated>2010-10-18T10:46:30.541-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Profiles'/><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><title type='text'>Getting Started with NServiceBus Part 7: Custom Performance Counters</title><content type='html'>Out of the box, NSB gives you a performance counter that tells you hold old the oldest message in the queue is.  This gives you an idea as to how long messages are sitting in the queue.  We decided to add a couple of new counters to tell us some other things about our performance.  &lt;br /&gt;&lt;br /&gt;The first one is what is the average processing time for a message?  This is the time from when the message was pulled off the queue until the time the transaction completes.  What this won't give us is granularity in determining which message handlers are moving slowly.  Since most installations will have only a single or small amount of message handlers, this should be good enough for us.  &lt;br /&gt;&lt;br /&gt;The second counter is how many failures do I have per second?  This is important since NSB has built-in retry logic.  We have no visibility to failures unless we look at the log as processing occurs or waiting until the message moves to the error queue.  We wanted to see quickly if we were processing slowing due to a lot of errors.&lt;br /&gt;&lt;br /&gt;To get this going we can create a new profile similar to the NServiceBus.PerformanceCounters profile in NSB.  First we create some classes to represent out monitoring:&lt;br /&gt;&lt;pre class="brush:c#"&gt;    public class Monitoring : IProfile { }&lt;br /&gt;    public class InstallMonitoring : IProfile { }&lt;br /&gt;&lt;/pre&gt;We have to have 2 profiles, one for running the counters and one for installing the counters.  We'll cover the installation first.  The first thing we need to do is remove the counters and reinstall them if they exist.&lt;br /&gt;&lt;pre class="brush:c#"&gt;        public void ProfileActivated()&lt;br /&gt;        {&lt;br /&gt;            Logger.Debug("Starting installation of  monitoring");&lt;br /&gt;&lt;br /&gt;            if (PerformanceCounterCategory.Exists(CategoryName))&lt;br /&gt;            {&lt;br /&gt;                Logger.Warn(String.Format("Category {0} already exists, going to delete it first", CategoryName));&lt;br /&gt;                PerformanceCounterCategory.Delete(CategoryName);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            CounterCreationDataCollection counterData = new CounterCreationDataCollection();&lt;br /&gt;&lt;br /&gt;            counterData.AddRange(this.InstallAverageMessageProcessTimeCounter());&lt;br /&gt;            counterData.AddRange(this.InstalledFailedMessageProcessingCounter());&lt;br /&gt;&lt;br /&gt;            PerformanceCounterCategory.Create(CategoryName, "NServiceBus Monitoring", PerformanceCounterCategoryType.MultiInstance, counterData);&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;/pre&gt;Once we've ditched the counter we rebuild it by creating some counter data.  I'll show one of the installs.  To calculate the average time of something we need to do two things.  We need to increment the time and also increment the basis of the event.  The basis must be added after the average timer(you'll get an error if you don't).&lt;br /&gt;&lt;pre class="brush:c#"&gt;        private CounterCreationDataCollection InstallAverageMessageProcessTimeCounter()&lt;br /&gt;        {&lt;br /&gt;            Logger.Debug("Starting installation of average process time monitoring");&lt;br /&gt;&lt;br /&gt;            CounterCreationDataCollection counterData = new CounterCreationDataCollection();&lt;br /&gt;&lt;br /&gt;            CounterCreationData avgTime = new CounterCreationData(AvgProcessTimeCounterName, &lt;br /&gt;                "Avg message processing time", &lt;br /&gt;                PerformanceCounterType.AverageTimer32);&lt;br /&gt;&lt;br /&gt;            counterData.Add(avgTime);&lt;br /&gt;&lt;br /&gt;            CounterCreationData avgBase = new CounterCreationData(AvgProcessTimeBaseCounterName, &lt;br /&gt;                "Avg message processing time base", &lt;br /&gt;                PerformanceCounterType.AverageBase);&lt;br /&gt;&lt;br /&gt;            counterData.Add(avgBase);&lt;br /&gt;&lt;br /&gt;            Logger.Debug("Installation of average processing time monitoring successful.");&lt;br /&gt;&lt;br /&gt;            return counterData;&lt;br /&gt;        }&lt;br /&gt;&lt;/pre&gt;Now that we have our counters installed, we need to create the profile to actual post to the counters.  When your profile is activated, we'll tie into 2 key events in the NSB runtime, "StartedMessageProcessing" and "FinishedMessageProcessing".  In doing so we can calculate the time that has elapsed and update our basis.  We'll use a simple StopWatch to keep track of it all.&lt;br /&gt;&lt;pre class="brush:c#"&gt;        private void MonitorAverageMessageProcessTime()&lt;br /&gt;        {&lt;br /&gt;            PerformanceCounter avgProcessTimeCounter = null;&lt;br /&gt;            PerformanceCounter avgProcessTimeBaseCounter = null;&lt;br /&gt;            Stopwatch watch = null;&lt;br /&gt;&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                avgProcessTimeCounter = new PerformanceCounter(CategoryName, AvgProcessTimeCounterName, Program.EndpointId, false);&lt;br /&gt;                avgProcessTimeBaseCounter = new PerformanceCounter(CategoryName, AvgProcessTimeBaseCounterName, Program.EndpointId, false);&lt;br /&gt;            }&lt;br /&gt;            catch (Exception e)&lt;br /&gt;            {&lt;br /&gt;                throw new InvalidOperationException("NServiceBus monitoring is not set up correctly. Running this process with the flag NServiceBus.InstallMonitoring should fix the problem.", e);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            GenericHost.ConfigurationComplete +=&lt;br /&gt;                (o, e) =&amp;gt;&lt;br /&gt;                {&lt;br /&gt;                    ITransport transport = Configure.Instance.Builder.Build&amp;lt;ITransport&amp;gt;();&lt;br /&gt;                    transport.StartedMessageProcessing += (s, ea) =&amp;gt; { watch = Stopwatch.StartNew(); };&lt;br /&gt;                    transport.FinishedMessageProcessing +=&lt;br /&gt;                        (s, ea) =&amp;gt;&lt;br /&gt;                        {&lt;br /&gt;                            watch.Stop();&lt;br /&gt;                            avgProcessTimeCounter.IncrementBy(watch.ElapsedTicks);&lt;br /&gt;                            avgProcessTimeBaseCounter.Increment();&lt;br /&gt;                        };&lt;br /&gt;                };&lt;br /&gt;        }&lt;br /&gt;&lt;/pre&gt;Please note that since we are posting to a counter for each message this will somewhat degrade the performance.  All we have to do now is run our process once with the "InstallMonitoring" profile to install the counters and then again with the "Monitoring" profile to post to the counters.  You must have the process running before you see anything in PerfMon.  When you fire PerfMon up, you should see something like this:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_sC2VEzP-9qE/TLyGCCRX3DI/AAAAAAAAA2M/vIcEBmte3X4/s1600/nsb_perfmon_counters.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="475" src="http://2.bp.blogspot.com/_sC2VEzP-9qE/TLyGCCRX3DI/AAAAAAAAA2M/vIcEBmte3X4/s640/nsb_perfmon_counters.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Since we installed the counters as Multi-Instance you should see multiple entries for each process running. &amp;nbsp;I have a simple Request/Response sample that I used to test this out. &amp;nbsp;Once you get sample running you can send a bunch of messages and start to see some data:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_sC2VEzP-9qE/TLyGbe76cmI/AAAAAAAAA2Q/RvIR8NWOeeg/s1600/nsb_perfmon_counter_data.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="466" src="http://3.bp.blogspot.com/_sC2VEzP-9qE/TLyGbe76cmI/AAAAAAAAA2Q/RvIR8NWOeeg/s640/nsb_perfmon_counter_data.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Sweet! &amp;nbsp;Now we have some additional ways we can monitor NSB. &amp;nbsp;As always, code can be found here:&amp;nbsp;&lt;a href="http://github.com/afyles/Blog/tree/master/NServiceBusExplorer/"&gt;http://github.com/afyles/Blog/tree/master/NServiceBusExplorer/&lt;/a&gt;&amp;nbsp;&amp;nbsp;Take a look at the "Profiles" project and the "RequestResponse" projects.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-7545967597053314914?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/7545967597053314914/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2010/10/getting-started-with-nservicebus-part-7.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/7545967597053314914'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/7545967597053314914'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2010/10/getting-started-with-nservicebus-part-7.html' title='Getting Started with NServiceBus Part 7: Custom Performance Counters'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_sC2VEzP-9qE/TLyGCCRX3DI/AAAAAAAAA2M/vIcEBmte3X4/s72-c/nsb_perfmon_counters.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-6080016170983322704</id><published>2010-10-08T06:07:00.000-07:00</published><updated>2010-10-08T06:07:28.287-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Saga'/><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><title type='text'>Getting Started with NServiceBus Part 6: MVC Music Store Saga(Workflow)</title><content type='html'>Last time were able to wire up the OrderAccepted event and publish to a single Shipping Subscriber. &amp;nbsp;This time around we are going to cast our net wider and include a Billing Subscriber. &amp;nbsp;This Subscriber will handle looking up the payment instrument for the order and then authorize that payment. &amp;nbsp;This presents a problem for our Shipping Subscriber as we cannot ship the product until we know the customer can pay for it. &lt;br /&gt;&lt;br /&gt;NSB handles this situation quite well by implementing Sagas or workflow. &amp;nbsp;With a Saga we can tell the Shipping Subscriber to wait for the payment authorization to complete before picking and shipping the order. &amp;nbsp;NSB handles this by allowing us to store the state of the workflow in persistent storage(Saga Persister). &amp;nbsp;Since this is handled for us, all we need to do is reconcile the state of the workflow and mark it complete when we are done.&lt;br /&gt;&lt;br /&gt;Let us begin by introducing a new entity, PaymentInstrument. &amp;nbsp;The easiest thing to do is create the table in the local DB and update the model from there.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_sC2VEzP-9qE/TK8Op2M7DpI/AAAAAAAAA2I/YjL17CRaEZ4/s1600/aspnet_music_store_payments.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_sC2VEzP-9qE/TK8Op2M7DpI/AAAAAAAAA2I/YjL17CRaEZ4/s1600/aspnet_music_store_payments.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;Next we'll create the message that the Shipping Subscriber will receive once the payment has been authorized or rejected.&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;/div&gt;&lt;pre class="brush:c#"&gt;    public interface IAuthorizePaymentEvent : IEvent&lt;br /&gt;    {&lt;br /&gt;        Int32 OrderId { get; set; }&lt;br /&gt;        Boolean Authorized { get; set; }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;In this message we simply tie back to the Order and send a flag giving us the status of the authorization.  To complete the Billing Subscriber we create a new project and configure the endpoint AsA_Server and point to our Publisher, the Music Store command handler input queue.  We need to add another endpoint to the config since we will be sending the Shipping Subscriber the IAuthroizePaymentEvent message.  The mappings are as follows:&lt;br /&gt;&lt;pre class="brush:xml"&gt;&lt;UnicastBusConfig&gt;&lt;br /&gt;    &lt;MessageEndpointMappings&gt;&lt;br /&gt;      &lt;!-- Since the command processor also does publishing, drop our subscription message on the same queue --&gt;&lt;br /&gt;      &lt;add Messages="Messages.IOrderAcceptedEvent,Messages" Endpoint="music_store_commands"/&gt;&lt;br /&gt;      &lt;add Messages="Messages.IAuthorizePaymentEvent,Messages" Endpoint="music_store_shipping" /&gt;&lt;br /&gt;    &lt;/MessageEndpointMappings&gt;&lt;br /&gt;  &lt;/UnicastBusConfig&gt;&lt;br /&gt;&lt;/pre&gt;All we have left is to complete the handler for the published IOrderAcceptedEvent.  In this handler we'll look up the user name on the order and the total.  Based on this information we'll grab the payment instrument for the user and do some simple validation.  Upon completion we'll send a message over to the Shipping Subscriber so it can continue the workflow.&lt;br /&gt;&lt;pre class="brush:c#"&gt;      public void Handle(IOrderAcceptedEvent message)&lt;br /&gt;      {&lt;br /&gt;            MusicStoreEntities storeDB = new MusicStoreEntities();&lt;br /&gt;&lt;br /&gt;            var order = storeDB.Orders.Single(o =&amp;gt; o.OrderId == message.OrderId);&lt;br /&gt;&lt;br /&gt;            var paymentInstrument = storeDB.PaymentInstruments.Single(pi =&amp;gt; pi.UserName == order.Username);&lt;br /&gt;&lt;br /&gt;            var authorizedEvent = this.Bus.CreateInstance&amp;lt;IAuthorizePaymentEvent&amp;gt;(p =&amp;gt; p.OrderId = order.OrderId);&lt;br /&gt;&lt;br /&gt;            // authorize the card...&lt;br /&gt;            if (order.Total &amp;lt; 100)&lt;br /&gt;                authorizedEvent.Authorized = true;&lt;br /&gt;            else&lt;br /&gt;                authorizedEvent.Authorized = false;&lt;br /&gt;&lt;br /&gt;            this.Bus.Send(authorizedEvent);&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;Now we have a Billing Subscriber that is authorizing payment instruments and sending messages to our Shipping Subscriber.  Now we have to do the work to make the Shipping Subscriber wait for the authorization.  Let's begin by defining the data or state that we'd like to keep track of.  At a bare minimum we need to keep track of the OrderId, the status of the payment authorization, and the status of the order(have we picked all the product?).  NSB will also impose a few extra fields upon us as we implement the IContainSagaData interface.&lt;br /&gt;&lt;pre class="brush:c#"&gt;    public class ShippingSagaData : IContainSagaData&lt;br /&gt;    {&lt;br /&gt;        public virtual Guid Id{ get; set; }&lt;br /&gt;        public virtual String OriginalMessageId { get; set; }&lt;br /&gt;        public virtual String Originator { get; set; }&lt;br /&gt;        public virtual Boolean PaymentAuthorized { get; set; }&lt;br /&gt;        public virtual Int32 OrderId { get; set; }&lt;br /&gt;        public virtual Boolean OrderPicked { get; set; }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;Note that all the properties are marked as virtual.  NSB uses NHibernate to store the Saga so we must give NH access to our properties.  If you run the code without this it will complain.  When implementing a Saga in NSB, your Saga becomes the handler and distributor of many messages.  NSB needs to know how to start the Saga, which messages to handle, and what kind of data to store.  The class definition says it all:&lt;br /&gt;&lt;pre class="brush:c#"&gt;public class ShippingSaga : Saga&amp;lt;ShippingSagaData&amp;gt;,&lt;br /&gt;        IAmStartedByMessages&amp;lt;IOrderAcceptedEvent&amp;gt;,&lt;br /&gt;        IHandleMessages&amp;lt;IAuthorizePaymentEvent&amp;gt;,&lt;br /&gt;        IHandleMessages&amp;lt;IOrderPickedEvent&amp;gt;&lt;br /&gt;&lt;/pre&gt;There is a new message here that we didn't have before.  We need to know when we have completed picking the product from our shelves so we've introduced the IOrderPickedEvent.&lt;br /&gt;&lt;pre class="brush:c#"&gt;    public interface IOrderPickedEvent : IEvent&lt;br /&gt;    {&lt;br /&gt;        Int32 ShippingNoteId { get; set; }&lt;br /&gt;        Int32 OrderId { get; set; }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;The first thing we have to do is tell NSB how to look up our Saga.  In other works, what makes a Saga unique?  In our case we link everything up by OrderId.  To make sure everything is unique we map all the message OrderIds to the Saga data OrderId.&lt;br /&gt;&lt;pre class="brush:c#"&gt;        public override void ConfigureHowToFindSaga()&lt;br /&gt;        {&lt;br /&gt;            base.ConfigureMapping&amp;lt;IOrderAcceptedEvent&amp;gt;(s =&amp;gt; s.OrderId, e =&amp;gt; e.OrderId);&lt;br /&gt;            base.ConfigureMapping&amp;lt;IAuthorizePaymentEvent&amp;gt;(s =&amp;gt; s.OrderId, e =&amp;gt; e.OrderId);&lt;br /&gt;            base.ConfigureMapping&amp;lt;IOrderPickedEvent&amp;gt;(s =&amp;gt; s.OrderId, e =&amp;gt; e.OrderId);&lt;br /&gt;        }&lt;br /&gt;&lt;/pre&gt;All of this is based off of the Order being accepted so our Saga starts by handling that event.  We'll default some Saga data and then kick of the picking process.&lt;br /&gt;&lt;pre class="brush:c#"&gt;        public void Handle(IOrderAcceptedEvent message)&lt;br /&gt;        {&lt;br /&gt;            base.Data.PaymentAuthorized = false;&lt;br /&gt;            base.Data.OrderId = message.OrderId;&lt;br /&gt;            base.Bus.SendLocal&amp;lt;IPickOrderCommand&amp;gt;( p =&amp;gt; p.OrderId = message.OrderId);&lt;br /&gt;        }&lt;br /&gt;&lt;/pre&gt;The interesting thing here is the Bus.SendLocal() method.  What this does is put a message on the current endpoint's queue.  We send a message to ourselves to kick of the pick process.  The handler for this was detailed last time as we checked our inventory positions for the product and created ship notes.  While we are picking the product, the payment is being authorized.  If the payment comes back unauthorized we'll simply restock the order.  Once we have picked the order we can check to see if we can let the order out the door.&lt;br /&gt;&lt;pre class="brush:c#"&gt;        public void Handle(IOrderPickedEvent message)&lt;br /&gt;        {&lt;br /&gt;            base.Data.OrderPicked = true;&lt;br /&gt;            this.TryComplete();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void TryComplete()&lt;br /&gt;        {&lt;br /&gt;            if (base.Data.OrderPicked &amp;&amp; Data.PaymentAuthorized)&lt;br /&gt;                MarkAsComplete();&lt;br /&gt;        }&lt;br /&gt;&lt;/pre&gt;The MarkAsComplete() method tells the NSB infrastructure that this Saga is over and we can ditch the state.  We also need to call the TryComplete() method if the authorization comes in:&lt;br /&gt;&lt;pre class="brush:c#"&gt;        public void Handle(IAuthorizePaymentEvent message)&lt;br /&gt;        {&lt;br /&gt;            base.Data.PaymentAuthorized = message.Authorized;&lt;br /&gt;            this.TryComplete();&lt;br /&gt;        }&lt;br /&gt;&lt;/pre&gt;We've completed our Saga except for one part.  Normally we would only wait for an payment instrument authorization for so long.  In our Saga we can request a timeout.  When a timeout is requested, a message is sent to another endpoint that watches the clock for us.  When time is up, the external endpoint sends us a message back.  In this example we aren't requesting a timeout which means we will wait forever for an authorization.  Normally we wouldn't do this and we'd have to run the Timeout Manager process that comes with NSB.  To keep it simple I left it out this time.  We still have to implement the Timeout() method, and in our case we'll simply kill the Saga for a timeout.&lt;br /&gt;&lt;pre class="brush:c#"&gt;        public override void Timeout(object state)&lt;br /&gt;        {&lt;br /&gt;            MarkAsComplete();&lt;br /&gt;        }&lt;br /&gt;&lt;/pre&gt;We've come a long way, we now have a music store that accepts Orders durably, handles payment authorization, picks the product, and creates shipping notes for the shipping dock.  As always, code can be found at github: http://github.com/afyles/Blog&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-6080016170983322704?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/6080016170983322704/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2010/10/getting-started-with-nservicebus-part-6.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/6080016170983322704'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/6080016170983322704'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2010/10/getting-started-with-nservicebus-part-6.html' title='Getting Started with NServiceBus Part 6: MVC Music Store Saga(Workflow)'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_sC2VEzP-9qE/TK8Op2M7DpI/AAAAAAAAA2I/YjL17CRaEZ4/s72-c/aspnet_music_store_payments.png' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-1290128758397258085</id><published>2010-10-04T06:20:00.000-07:00</published><updated>2010-10-04T06:20:18.132-07:00</updated><title type='text'>Monitoring NServiceBus: Performance Counters Starting Point</title><content type='html'>We are starting to look at monitoring NServiceBus internally and we're starting with PerfMon in our test and cert environments.  I've come up with short list of suggested counters to look at and thought I'd share then with everyone. &amp;nbsp;I'm also working on a set of custom counters for NSB that I'll be posting shortly on top of the one built in counter.&lt;br /&gt;&lt;br /&gt;• &lt;b&gt;.NET CLR Exceptions(NServiceBus.Host)\# of Exceps Thrown / sec &lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; o This will tell you if the app is throwing tons of exceptions, this is important as NSB will retry under&lt;br /&gt;exception scenarios and therefore you may be unaware that your app is blowing up&lt;br /&gt;&lt;br /&gt;• &lt;b&gt;.NET CLR Memory(NServiceBus.Host)\# of Pinned Objects &lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; o The number of objects GC can't move back into memory(leak or locked up thread)&lt;br /&gt;&lt;br /&gt;• &lt;b&gt;.NET CLR Memory(NServiceBus.Host)\% Time in GC &lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; o How long it takes to do a GC, this will tell us if our memory footprint is too big or out of control for some reason&lt;br /&gt;&lt;br /&gt;• &lt;b&gt;Distributed Transaction Coordinator\Transactions/sec &lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; o How many transactions is DTC pumping out&lt;br /&gt;&lt;br /&gt;• &lt;b&gt;MSMQ Queue(Computer Queues)\Messages in Queue &lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; o How many messages are in your NSB input queue&lt;br /&gt;&lt;br /&gt;• &lt;b&gt;MSMQ Queue(info-dev11\private$\nservicebus_error)\Messages in Queue &lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; o How many messages are in the error queue&lt;br /&gt;&lt;br /&gt;• &lt;b&gt;MSMQ Service\Incoming Messages/sec &lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; o Number of messages coming in, tells us if we are getting overloaded&lt;br /&gt;&lt;br /&gt;• &lt;b&gt;MSMQ Service\Outgoing Messages/sec &lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; o Number of messages going out, are we sending messages fast enough&lt;br /&gt;&lt;br /&gt;• &lt;b&gt;NServiceBus\* &lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; o Critical Time - how old is the oldest message in the queue?  This tells us we are processing messages slowly&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-1290128758397258085?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/1290128758397258085/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2010/10/monitoring-nservicebus-performance.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/1290128758397258085'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/1290128758397258085'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2010/10/monitoring-nservicebus-performance.html' title='Monitoring NServiceBus: Performance Counters Starting Point'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-3111987562948314783</id><published>2010-10-01T05:40:00.000-07:00</published><updated>2010-10-01T05:40:17.612-07:00</updated><title type='text'>Enabling NServiceBus Performance Counters</title><content type='html'>First you must install the counters using the Runner.exe tool.  The next thing you need to do is add the "NServiceBus.PerformanceCounters" profile to your install.  Without this you will not see any instances in PerfMon.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-3111987562948314783?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/3111987562948314783/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2010/10/enabling-nservicebus-performance.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/3111987562948314783'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/3111987562948314783'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2010/10/enabling-nservicebus-performance.html' title='Enabling NServiceBus Performance Counters'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-4516010249043957180</id><published>2010-09-21T14:03:00.000-07:00</published><updated>2010-09-21T14:03:42.965-07:00</updated><title type='text'>Unit Testing NSB with VS2010, .NET 4.0, and MSTest</title><content type='html'>Unit testing NSB can be done without NUnit.  For those of you using MSTest, you will have to download the latest trunk and compile NSB yourself to get this to work.  Otherwise you will get a bunch of TypeAccessExceptions amongst others.  The big difference on the trunk is that the Rhino Mocks reference has been pulled out which I think was causing the issue.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-4516010249043957180?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/4516010249043957180/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2010/09/unit-testing-nsb-with-vs2010-net-40-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/4516010249043957180'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/4516010249043957180'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2010/09/unit-testing-nsb-with-vs2010-net-40-and.html' title='Unit Testing NSB with VS2010, .NET 4.0, and MSTest'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-3475592487152400680</id><published>2010-09-19T07:05:00.000-07:00</published><updated>2010-10-08T05:24:19.404-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><category scheme='http://www.blogger.com/atom/ns#' term='CQRS'/><title type='text'>Getting Started with NServiceBus Part 5: MVC Music Store Basic Pub/Sub</title><content type='html'>To recap, thus far we've implemented a basic Command/Query Segregation pattern in the ASP.NET MVC Music Store application. &amp;nbsp;This has decoupled us from the UI for performing important operations which include allowing users to shop and place orders. &lt;br /&gt;&lt;br /&gt;Now we are going to expand upon our application to provide the facility to ship products. &amp;nbsp;The way we'll do this is by publishing a message when an Order has been accepted. &amp;nbsp;Publishing a message is&amp;nbsp;fundamentally&amp;nbsp;different than sending a message. &amp;nbsp;When you publish a message it is intended to be received by multiple parties. &amp;nbsp;Also you must be aware that there can only be one logical Publisher. &amp;nbsp;If you have multiple Publishers publishing the same message, then the system does not know who to listen to. &amp;nbsp;In our example we'll initially only have one Subscriber, the Shipping service. &amp;nbsp;The Shipping service will handle updating inventory and creating shipping notes for the shipping department. &amp;nbsp;In future installments we'll add more Subscribers to our Order Accepted message. &lt;br /&gt;&lt;br /&gt;To get started we have to enhance our data model a bit so we have some place to store our inventory and our shipping notes. &amp;nbsp;I found the hard way that it is significantly easier to update the database and then the model when using the Entity Framework. &amp;nbsp;That being said, we'll add the new tables to the database and then update the model:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_sC2VEzP-9qE/TJYQ4YPSh3I/AAAAAAAAA2A/oNbNsswMZKg/s1600/aspnet_music_store_model.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://4.bp.blogspot.com/_sC2VEzP-9qE/TJYQ4YPSh3I/AAAAAAAAA2A/oNbNsswMZKg/s400/aspnet_music_store_model.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;We start with our table of inventory positions, which tells us how much of the product we have on hand and how much we need to order. &amp;nbsp;When an order comes in, we'll check this table to see if we have the product, and if we do we'll add that to the Shipped Quantity on our shipping note. &amp;nbsp;If we don't have the product, we'll put it on back order on our note. &lt;br /&gt;&lt;br /&gt;The first thing we need to do is modify our Music Store command handler to become a Publisher. &amp;nbsp;This is a change to our EndpointConfig.cs which previously was configured AsA_Server. &amp;nbsp;We'll change this to be configured AsA_Publisher. &amp;nbsp;So what does this do for us? &amp;nbsp;First and foremost it tells the endpoint to expect to receive not only the messages we've defined, but also subscription messages. &amp;nbsp;When a Subscriber starts up, it will put a subscription message into the Publishers input queue, the SAME queue it is currently handling commands upon. &amp;nbsp;The AsA_Publisher configuration also configures NSB to handle things like how to store the subscription messages. &amp;nbsp;For the Lite profile, subscriptions are held in memory, for Integration the messages are stored in a queue, and for Production the messages are stored in a database(leveraging NHibernate). Below is our small tweak to the endpoint configuration:&lt;br /&gt;&lt;pre class="brush:c#"&gt;public class EndpointConfig : IConfigureThisEndpoint, AsA_Server&lt;br /&gt;    {&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;The next thing we need to do is actually publish the message.  To accomplish this, we'll modify the PlaceOrderHandler to publish a message after it has successfully saved the order.  The message we'll publish is the IOrderAcceptedEvent message:&lt;br /&gt;&lt;pre class="brush:c#"&gt;public interface IOrderAcceptedEvent : IEvent&lt;br /&gt;    {&lt;br /&gt;        Int32 OrderId { get; set; }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;This message has been added to our public schema project(Messages.csproj).  All we pass along here is the order id.  We can look up the Order on the other side when we go to ship the product, so there is no need to publish the entire Order.  There may be a reason to publish the entire order in the future, especially if there exists components that don't have a way to query for Orders.  Note that I'm using the naming convention of provided an "Event" suffix.  This is so that I can easily know what is an Event versus what is a Command(namespacing would also do).&lt;br /&gt;&lt;br /&gt;Now we have a message to publish, we can update our IPlaceOrderHandler.  The first thing we need to do is add a public property of type IBus so that NSB will inject a reference to the bus into our handler.  After we have the reference, at the end of the handler we call Bus.Publish and provide an instance of the message using an Action:&lt;br /&gt;&lt;pre class="brush:c#"&gt;public class IPlaceOrderHandler : IHandleMessages&amp;lt;IPlaceOrderCommand&amp;gt;&lt;br /&gt;    {&lt;br /&gt;        public IBus Bus { get; set; }&lt;br /&gt;&lt;br /&gt;        public void Handle(IPlaceOrderCommand message)&lt;br /&gt;        {&lt;br /&gt;            MusicStoreEntities storeDB = new MusicStoreEntities();&lt;br /&gt;&lt;br /&gt;            var order = new MvcMusicStore.Models.Order();&lt;br /&gt;&lt;br /&gt;            order.Username = message.UserId;&lt;br /&gt;            order.OrderDate = DateTime.Now;&lt;br /&gt;            order.OrderId = message.OrderId;&lt;br /&gt;&lt;br /&gt;            // Save Order&lt;br /&gt;            storeDB.AddToOrders(order);&lt;br /&gt;            storeDB.SaveChanges();&lt;br /&gt;&lt;br /&gt;            //Process the order&lt;br /&gt;            var cart = new ShoppingCart(message.CartId);&lt;br /&gt;&lt;br /&gt;            cart.CreateOrder(order);&lt;br /&gt;&lt;br /&gt;            this.Bus.Publish&amp;lt;IOrderAcceptedEvent&amp;gt;( o =&amp;gt; o.OrderId = order.OrderId);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;Now we have our handler publishing messages out to the bus for all subscribers.  Next we'll build up our Shipping Subscriber.  Add a new project and configure the endpoint AsA_Server just like our original command handler.  Next we'll take a look at how we reference the Publisher.  We need to know where to drop off our subscription messages.  In our subscription message is the Subscriber address along with some other endpoint information.  By giving our address to the Publisher, it knows where to push published messages to.  To achieve this we add a reference to the Publisher in our app.config:&lt;br /&gt;&lt;pre class="brush:xml"&gt;&lt;msmqtransportconfig errorqueue="nservicebus_error" inputqueue="music_store_shipping" maxretries="2" numberofworkerthreads="1"&gt;&lt;br /&gt;&lt;br /&gt;  &lt;unicastbusconfig&gt;&lt;br /&gt;    &lt;messageendpointmappings&gt;&lt;br /&gt;      &lt;br /&gt;      &lt;add endpoint="music_store_commands" messages="Messages"&gt;&lt;br /&gt;    &lt;/add&gt;&lt;/messageendpointmappings&gt;&lt;br /&gt;  &lt;/unicastbusconfig&gt;&lt;br /&gt;&lt;/msmqtransportconfig&gt;&lt;/pre&gt;The overall pub/sub semantics goes something like this:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Publisher starts up and loads subscriptions from storage(memory, queue, or DB)&lt;/li&gt;&lt;li&gt;Subscriber starts up and sends a subscription message to the Publisher. &amp;nbsp;If the Publisher already has stored the subscription, it gets ignored. &amp;nbsp;If it does not have the subscription, store the message.&lt;/li&gt;&lt;li&gt;Publisher makes a call to Bus.Publish.&lt;/li&gt;&lt;li&gt;Publisher looks to see who is subscribed to that message. &amp;nbsp;It creates a message for each Subscriber and puts it on its outbound queue(this is an internal queue to MSMQ that you don't see unless it is sending the machine to another machine)&lt;/li&gt;&lt;li&gt;MSMQ takes over and pushes the messages to their destination queues. &amp;nbsp;&lt;/li&gt;&lt;li&gt;If the subscriber is up and running it will receive the message and call the appropriate handler. &amp;nbsp;If not, the message remains in the subscriber input queue.&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;Please note that if you have a lot of Subscribers and their queues are down, the messages will build up on the Publishers' outbound queue so you will have to size your storage appropriately.&lt;/div&gt;&lt;div&gt;The last thing we need to do is implement the logic for the Shipping service.  We will hydrate the order from the order id in the message and then check our inventory.  If we have the product, we ship it, otherwise we back order it.  From there our processing is complete and we have a full implementation of Pub/Sub:&lt;br /&gt;&lt;pre class="brush:c#"&gt;public class ShippingHandler : IHandleMessages&amp;lt;IOrderAcceptedEvent&amp;gt;&lt;br /&gt;    {&lt;br /&gt;        #region IMessageHandler&amp;lt;IOrderAcceptedEvent&amp;gt; Members&lt;br /&gt;&lt;br /&gt;        public void Handle(IOrderAcceptedEvent message)&lt;br /&gt;        {&lt;br /&gt;            MusicStoreEntities storeDB = new MusicStoreEntities();&lt;br /&gt;&lt;br /&gt;            var order = storeDB.Orders.Single(o =&amp;gt; o.OrderId == message.OrderId);&lt;br /&gt;&lt;br /&gt;            var shipNote = new ShippingNote&lt;br /&gt;            { &lt;br /&gt;                FirstName = order.FirstName,&lt;br /&gt;                LastName = order.LastName,&lt;br /&gt;                Address = order.Address,&lt;br /&gt;                City = order.City,&lt;br /&gt;                State = order.State,&lt;br /&gt;                PostalCode = order.PostalCode&lt;br /&gt;            };&lt;br /&gt;&lt;br /&gt;            foreach (var detail in order.OrderDetails)&lt;br /&gt;            {&lt;br /&gt;                var inventoryPosition = storeDB.InventoryPositions.Single(p =&amp;gt; p.Album.AlbumId == detail.AlbumId);&lt;br /&gt;&lt;br /&gt;                if (inventoryPosition.BalanceOnHand &amp;gt;= detail.Quantity)&lt;br /&gt;                {&lt;br /&gt;                    inventoryPosition.BalanceOnHand -= detail.Quantity;&lt;br /&gt;                    shipNote.ShippedQuantity += detail.Quantity;&lt;br /&gt;                }&lt;br /&gt;                else&lt;br /&gt;                {&lt;br /&gt;                    shipNote.BackOrderQuantity = detail.Quantity - shipNote.ShippedQuantity;&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            storeDB.AddToShippingNotes(shipNote);&lt;br /&gt;&lt;br /&gt;            storeDB.SaveChanges();&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        #endregion&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;Code is at &lt;a href="http://github.com/afyles/Blog"&gt;github&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-3475592487152400680?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/3475592487152400680/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2010/09/getting-started-with-nservicebus-part-5.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/3475592487152400680'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/3475592487152400680'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2010/09/getting-started-with-nservicebus-part-5.html' title='Getting Started with NServiceBus Part 5: MVC Music Store Basic Pub/Sub'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_sC2VEzP-9qE/TJYQ4YPSh3I/AAAAAAAAA2A/oNbNsswMZKg/s72-c/aspnet_music_store_model.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-8762948740672438227</id><published>2010-09-08T14:50:00.000-07:00</published><updated>2010-09-08T14:50:18.484-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><title type='text'>Fix It!  Where did my project startup settings go?</title><content type='html'>One thing you'll notice pretty quickly when using NSB and source control is that your Debug settings get lost once you check-in. &lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_sC2VEzP-9qE/TIgEdgdRHwI/AAAAAAAAA14/t4npoBYDzIo/s1600/DebugSettings.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="245" src="http://2.bp.blogspot.com/_sC2VEzP-9qE/TIgEdgdRHwI/AAAAAAAAA14/t4npoBYDzIo/s400/DebugSettings.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;This is because these settings are in the $project.user file and not part of the actual $project.csproj file. &amp;nbsp;To fix this, simply add the properties to a PropertyGroup in your project file:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:xml"&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;startaction&gt;Program&lt;/startaction&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;startprogram&gt;$(ProjectDir)$(OutputPath)NServiceBus.Host.exe&lt;/startprogram&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;startarguments&gt;NServiceBus.Integration&lt;/startarguments&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-8762948740672438227?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/8762948740672438227/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2010/09/fix-it-where-did-my-project-startup.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/8762948740672438227'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/8762948740672438227'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2010/09/fix-it-where-did-my-project-startup.html' title='Fix It!  Where did my project startup settings go?'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_sC2VEzP-9qE/TIgEdgdRHwI/AAAAAAAAA14/t4npoBYDzIo/s72-c/DebugSettings.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-6650365255350418096</id><published>2010-09-07T08:38:00.000-07:00</published><updated>2010-09-07T08:38:35.567-07:00</updated><title type='text'>Fix It! NServiceBus Host Crashes with TNS-less Oracle Connections</title><content type='html'>Come to find out if you are connecting to Oracle with a TNS-less connection, DTC gets all nutty and crashes your NSB host.  The fix is to use TNS.  This may not be ideal for some, but for most cases the abstraction layer from the application is nice.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-6650365255350418096?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/6650365255350418096/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2010/09/fix-it-nservicebus-host-crashes-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/6650365255350418096'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/6650365255350418096'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2010/09/fix-it-nservicebus-host-crashes-with.html' title='Fix It! NServiceBus Host Crashes with TNS-less Oracle Connections'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-5712262602721791772</id><published>2010-09-06T14:29:00.000-07:00</published><updated>2010-09-06T14:29:20.398-07:00</updated><title type='text'>Getting Started with NServiceBus Part 4: Handling Messages</title><content type='html'>Last time we plugged NSB into the Music Store web app and configured a one way method communication to the server.  From there, we'll pick up the messages and start processing them on the server side.  The first bit of setup we need to do is to create a new class library and add a reference to our Messages assembly and also all of the NSB assemblies.  &lt;br /&gt;&lt;br /&gt;First we'll add an configuration file and new class named "EndpointConfig" to handle all of our configuration needs.  Let's start with the app.config.  In the app config we'll need to configure how clients will send us messages by using the MsmqTransportConfig section.  Since we'll be interacting with the Music Store database, we'll need connection strings as well.  Here is the app.config:&lt;br /&gt;&lt;pre class="brush:xml"&gt;  &lt;configSections&gt;&lt;br /&gt;    &lt;section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core"/&gt;&lt;br /&gt;  &lt;/configSections&gt;&lt;br /&gt;  &lt;MsmqTransportConfig InputQueue="music_store_commands" ErrorQueue="nservicebus_error" NumberOfWorkerThreads="1" MaxRetries="5"/&gt;&lt;br /&gt;&lt;br /&gt;  &lt;connectionStrings&gt;&lt;br /&gt;    &lt;add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=C:\dev\git\blog\MvcMusicStore-v0.8\Source\MvcMusicStore\App_Data\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" /&gt;&lt;br /&gt;    &lt;add name="MusicStoreEntities" connectionString="metadata=res://Models/StoreDB.csdl|res://Models/StoreDB.ssdl|res://Models/StoreDB.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;Data Source=.\SQLEXPRESS;AttachDbFilename=C:\dev\git\blog\MvcMusicStore-v0.8\Source\MvcMusicStore\App_Data\MvcMusicStore.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True&amp;quot;" providerName="System.Data.EntityClient" /&gt;&lt;br /&gt;  &lt;/connectionStrings&gt;&lt;br /&gt;&lt;/pre&gt;The MsmqTransportConfig section defines four main properties.  The InputQueue property tells our web app where to put the messages.  The ErrorQueue property is where our messages will go if they cannot be processed after the configured amount of retries.  The number of retries is configured using the MaxRetries property.  The NumberOfWorkerThreads specifies how many threads will be spun up to read messages from the queue and process them.  Initially you should start with one and ramp the threads up from there if necessary.&lt;br /&gt;&lt;br /&gt;The next piece of the configuration puzzle is the EndpointConfig class.  This class will get picked up by NSB at startup and will be used to instruct NSB how to configure the end point.&lt;br /&gt;&lt;pre class="brush:c#"&gt;    public class EndpointConfig : IConfigureThisEndpoint, AsA_Server&lt;br /&gt;    {&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;The IConfigureThisEndpoint is an interface that marks the class for NSB to pick up during configuration.  The AsA_Server interface tells NSB to configure an endpoint that is transactional and that does not purge messages.  Now that we have NSB configured, we can start getting into the message handlers.&lt;br /&gt;&lt;br /&gt;In order to handle messages, you must implement the IHandleMessages&amp;lt;T&amp;gt; interface.  T in this case will be the interface your message type is based upon.  Let's check out the AddToCartHandler:&lt;br /&gt;&lt;pre class="brush:c#"&gt; public class AddToCartHandler : IHandleMessages&lt;IAddToCartCommand&gt;&lt;br /&gt;    {&lt;br /&gt;        public void Handle(IAddToCartCommand message)&lt;br /&gt;        {&lt;br /&gt;            MusicStoreEntities storeDB = new MusicStoreEntities();&lt;br /&gt;&lt;br /&gt;            // Retrieve the album from the database&lt;br /&gt;            var addedAlbum = storeDB.Albums&lt;br /&gt;                .Single(album =&gt; album.AlbumId == message.AlbumId);&lt;br /&gt;&lt;br /&gt;            // Add it to the shopping cart&lt;br /&gt;            var cart = new ShoppingCart( message.CartId );&lt;br /&gt;&lt;br /&gt;            cart.AddToCart(addedAlbum);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;Note that the method is void since we are processing the messages in a completely different app domain that the web site.  Once the interface has been implemented, it is straight .NET programming from there.  We do the same for the PlaceOrderHandler:&lt;br /&gt;&lt;pre class="brush:c#"&gt;public void Handle(IPlaceOrderCommand message)&lt;br /&gt;        {&lt;br /&gt;            MusicStoreEntities storeDB = new MusicStoreEntities();&lt;br /&gt;&lt;br /&gt;            var order = new MvcMusicStore.Models.Order();&lt;br /&gt;&lt;br /&gt;            order.Username = message.UserId;&lt;br /&gt;            order.OrderDate = DateTime.Now;&lt;br /&gt;            order.OrderId = message.OrderId;&lt;br /&gt;&lt;br /&gt;            // Save Order&lt;br /&gt;            storeDB.AddToOrders(order);&lt;br /&gt;            storeDB.SaveChanges();&lt;br /&gt;&lt;br /&gt;            //Process the order&lt;br /&gt;            var cart = new ShoppingCart(message.CartId);&lt;br /&gt;&lt;br /&gt;            cart.CreateOrder(order);&lt;br /&gt;        }&lt;br /&gt;&lt;/pre&gt;Note that we are taking the order id from the client.  This is because we must show the user the order id right after they have ordered on the client side.  We have to modify the underlying data model in order to accommodate this requirement.  Simply edit the Order and Order Details tables in the models so that their ids are not generated by the database.  Lastly, to get our server up and running we need to edit the Debug properties of the project.  First build the project and then set the Debug session to start using an external program.  Point to the generic host that comes with NSB, NServiceBus.Host.exe(in the bin directory).&lt;br /&gt;&lt;br /&gt;Now we can start adding things to our cart and placing orders from the UI.  What you'll notice right away is that when we add things to the cart, it shows us the cart.  Under normal conditions(Request/Response design) this would be ok, but our album may not have been saved to the database yet.  Therefore we need to change the UI so that it shows the album from the client side instead of the server side.  We can do this by creating a new action and showing everything client side:&lt;br /&gt;&lt;pre class="brush:c#"&gt;public ActionResult AddedItemToCart(int id)&lt;br /&gt;        {&lt;br /&gt;            var cart = ShoppingCart.GetCart(this.HttpContext);&lt;br /&gt;&lt;br /&gt;            // Retrieve the album from the database&lt;br /&gt;            var addedAlbum = storeDB.Albums&lt;br /&gt;                .Single(album =&gt; album.AlbumId == id);&lt;br /&gt;&lt;br /&gt;            // Set up our ViewModel&lt;br /&gt;            var viewModel = new ShoppingCartViewModel&lt;br /&gt;            {&lt;br /&gt;                CartItems = new System.Collections.Generic.List&lt;Cart&gt;(),&lt;br /&gt;                CartTotal = cart.GetTotal() + addedAlbum.Price&lt;br /&gt;            };&lt;br /&gt;&lt;br /&gt;            viewModel.CartItems.Add(new Cart { Album = addedAlbum, AlbumId = addedAlbum.AlbumId, Count = 1 });&lt;br /&gt;&lt;br /&gt;            return View(viewModel);&lt;br /&gt;        }&lt;br /&gt;&lt;/pre&gt;All we have to do now is redirect to our new action instead of the old one(Index):&lt;br /&gt;&lt;pre class="brush:c#"&gt;// Go back to the main store page for more shopping&lt;br /&gt;return RedirectToAction("AddedItemToCart", new { id = addedAlbum.AlbumId } );&lt;br /&gt;&lt;/pre&gt;You'll also note that you may get an error when placing an order.  The Music Store immediately validates against the database that your order is there.  This is now an unnecessary step because via messaging we are guaranteeing the delivery of the order. All we need to do is simply comment out all the validation code:&lt;br /&gt;&lt;pre class="brush:c#"&gt;public ActionResult Complete(int id)&lt;br /&gt;        {&lt;br /&gt;            //// Validate customer owns this order&lt;br /&gt;            //bool isValid = storeDB.Orders.Any(&lt;br /&gt;            //    o =&gt; o.OrderId == id &amp;&amp;&lt;br /&gt;            //    o.Username == User.Identity.Name);&lt;br /&gt;&lt;br /&gt;            //if (isValid)&lt;br /&gt;            //{&lt;br /&gt;            //    return View(id);&lt;br /&gt;            //}&lt;br /&gt;            //else&lt;br /&gt;            //{&lt;br /&gt;            //    return View("Error");&lt;br /&gt;            //}&lt;br /&gt;&lt;br /&gt;            return View(id);&lt;br /&gt;        }&lt;br /&gt;&lt;/pre&gt;Now with our minor tweaks to the UI we have fully implemented NSB in our Music Store application.  We can guarantee that our users will be able to shop and place orders even if our database is down.  This becomes increasingly important especially for those big spenders, we don't want to have to tell them to start all over and that we lost their order.  &lt;br /&gt;&lt;br /&gt;Full code can be found &lt;a href="http://github.com/afyles/Blog/tree/master/MvcMusicStore-v0.8/"&gt;here&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-5712262602721791772?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/5712262602721791772/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2010/09/getting-started-with-nservicebus-part-4.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/5712262602721791772'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/5712262602721791772'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2010/09/getting-started-with-nservicebus-part-4.html' title='Getting Started with NServiceBus Part 4: Handling Messages'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-1042957872173214020</id><published>2010-08-25T07:50:00.000-07:00</published><updated>2010-08-25T08:01:32.523-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><title type='text'>Getting Started with NServiceBus Part 3: Putting Messages on the Bus</title><content type='html'>Last time we analyzed the Music Store code to come up with a schema for our messages.  The next order of business is to modify the Music Store code to put messages on the bus.  In order to do this we must first edit our web.config file to configure NSB.  First you have to add the custom config section:&lt;br /&gt;&lt;pre class="brush:xml"&gt;&lt;section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core"&gt;&lt;/section&gt;&lt;br /&gt;&lt;/pre&gt;Next we add that section to create an Endpoint Mapping.  What this does is tell the bus that the given Endpoint will be accepting messages defined in our schema assembly.&lt;br /&gt;&lt;pre class="brush:xml"&gt;&lt;unicastbusconfig&gt;&lt;br /&gt;    &lt;messageendpointmappings&gt;&lt;br /&gt;      &lt;add Messages="Messages" Endpoint="music_store_commands"/&gt;&lt;br /&gt;    &lt;/MessageEndpointMappings&gt;&lt;br /&gt;  &lt;/UnicastBusConfig&gt;&lt;br /&gt;&lt;/pre&gt;In our case the Endpoint is the address to the queue that will be accepting our messages.  If you want at this point you can create this as a local, private, transactional MSMQ queue.  Also be sure to have the Distributed Transaction Coordinator service up and running.  Now that we have configured our Endpoint, we have to bootstrap NServiceBus and keep it going for the duration of our ASP.NET application.  We can do this in the Global.asax.cs file using NSB's fluent configuration:&lt;br /&gt;&lt;pre class="brush:c#"&gt;protected void Application_Start()&lt;br /&gt;        {&lt;br /&gt;            AreaRegistration.RegisterAllAreas();&lt;br /&gt;&lt;br /&gt;            RegisterRoutes(RouteTable.Routes);&lt;br /&gt;&lt;br /&gt;            Bus = NServiceBus.Configure.WithWeb()&lt;br /&gt;                .Log4Net()&lt;br /&gt;                .DefaultBuilder()&lt;br /&gt;                .XmlSerializer()&lt;br /&gt;                .MsmqTransport()&lt;br /&gt;                    .IsTransactional(false)&lt;br /&gt;                    .PurgeOnStartup(false)&lt;br /&gt;                .UnicastBus()&lt;br /&gt;                    .ImpersonateSender(false)&lt;br /&gt;                .CreateBus()&lt;br /&gt;                .Start();&lt;br /&gt;        }&lt;br /&gt;&lt;/pre&gt;I'll explain each configuration item bit by bit:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;WithWeb - tells NSB to scan a web directory instead of a regular one&lt;/li&gt;&lt;li&gt;Log4Net - next configure Log4Net for logging&lt;/li&gt;&lt;li&gt;DefaultBuilder - use the default IoC container&lt;/li&gt;&lt;li&gt;XmlSerializer - serialize objects using XML&lt;/li&gt;&lt;li&gt;MsmqTransport - configure MSMQ as our transportation protocol&lt;/li&gt;&lt;li&gt;IsTransactional(false) - we don't want to hang a web app up in transactions, so turn this off&lt;/li&gt;&lt;li&gt;PurgeOnStartup(false) - since there is no queue for us to purge, turn this off&lt;/li&gt;&lt;li&gt;UnicastBus - configure our bus to send single point to point messages&lt;/li&gt;&lt;li&gt;ImpersonateSender(false) - turn off impersonation&lt;/li&gt;&lt;li&gt;CreateBus() - tell the IoC to create an instance of the bus&lt;/li&gt;&lt;li&gt;Start() - bootstrap the bus&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Now that we've bootstrapped, NSB we can get on to sending messages.  Our first message will be used to add something to a cart in the database.  We head to the the ShoppingCartController.AddToCart method and modify it to send a message instead of interacting directly with the database.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:c#"&gt;public ActionResult AddToCart(int id)&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            // Retrieve the album from the database&lt;br /&gt;            var addedAlbum = storeDB.Albums&lt;br /&gt;                .Single(album =&gt; album.AlbumId == id);&lt;br /&gt;&lt;br /&gt;            // Add it to the shopping cart&lt;br /&gt;            var cart = ShoppingCart.GetCart(this.HttpContext);&lt;br /&gt;            &lt;br /&gt;            //cart.AddToCart(addedAlbum);&lt;br /&gt;&lt;br /&gt;            Helpers.ServiceAgent&amp;lt;IAddToCartCommand&amp;gt;.Send(&lt;br /&gt;                c =&gt; &lt;br /&gt;                {&lt;br /&gt;                    c.CartId = cart.GetCartId(this.HttpContext);&lt;br /&gt;                    c.AlbumId = addedAlbum.AlbumId;&lt;br /&gt;                });&lt;br /&gt;           &lt;br /&gt;            // Go back to the main store page for more shopping&lt;br /&gt;            return RedirectToAction("Index");&lt;br /&gt;        }&lt;br /&gt;&lt;/pre&gt;I've added a utility class to actually put the message on the bus using similar NSB semantics.  I'm doing this so that I don't have an explicit reference to NSB in my Controller code.  The utility is very simple:&lt;br /&gt;&lt;pre class="brush:c#"&gt;public static class ServiceAgent&amp;lt;T&amp;gt; where T : ICommand&lt;br /&gt;    {&lt;br /&gt;        public static void Send(Action&amp;lt;T&amp;gt; messageConstructor)&lt;br /&gt;        {&lt;br /&gt;            if (null != messageConstructor)&lt;br /&gt;                MvcApplication.Bus.Send&amp;lt;T&amp;gt;(messageConstructor);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;We'll do the same thing for placing an order. We modify the code in CheckOutController.AddressAndPayment:&lt;br /&gt;&lt;pre class="brush:c#"&gt;[HttpPost]&lt;br /&gt;        public ActionResult AddressAndPayment(FormCollection values)&lt;br /&gt;        {&lt;br /&gt;            ...&lt;br /&gt;                else&lt;br /&gt;                {&lt;br /&gt;                    //order.Username = User.Identity.Name;&lt;br /&gt;                    //order.OrderDate = DateTime.Now;&lt;br /&gt;&lt;br /&gt;                    //Save Order&lt;br /&gt;                    //storeDB.AddToOrders(order);&lt;br /&gt;                    //storeDB.SaveChanges();&lt;br /&gt;&lt;br /&gt;                    //Process the order&lt;br /&gt;                    var cart = ShoppingCart.GetCart(this.HttpContext);&lt;br /&gt;                    //cart.CreateOrder(order);&lt;br /&gt;&lt;br /&gt;                    Int32 syntheticId = Helpers.IdGenerator.Generate();&lt;br /&gt;&lt;br /&gt;                    Helpers.ServiceAgent&lt;iplaceordercommand&gt;.Send(&lt;br /&gt;                        c =&gt;&lt;br /&gt;                        {&lt;br /&gt;                            c.OrderId = syntheticId;&lt;br /&gt;                            c.CartId = cart.GetCartId(this.HttpContext);&lt;br /&gt;                        });&lt;br /&gt;&lt;br /&gt;                    &lt;br /&gt;                    &lt;br /&gt;                    return RedirectToAction("Complete", &lt;br /&gt;                        new { id = syntheticId });&lt;br /&gt;                }&lt;br /&gt;            ...&lt;br /&gt;        }&lt;br /&gt;&lt;/pre&gt;Here we're using the same utility class to put a message on the bus.  Note that I'm generating the Order Id on the &lt;i&gt;client side&lt;/i&gt;.  This application shows the order id back to the user after they have placed the order.  In order to pull this off, we have to create the id client site.  I've created another utility to generate the Order Id:&lt;br /&gt;&lt;pre class="brush:c#"&gt;public static class IdGenerator&lt;br /&gt;    {&lt;br /&gt;        public static Int32 Generate()&lt;br /&gt;        {&lt;br /&gt;            byte[] buffer = Guid.NewGuid().ToByteArray();&lt;br /&gt;            return BitConverter.ToInt32(buffer, 0);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;Now if you fire up the client and try to add items to the cart, you won't see any data in the subsequent screen.  This is because we haven't implemented the server side to our solution that handles the messages.  When placing an order you should see and order id just like you normally would.&lt;br /&gt;&lt;br /&gt;Next time we'll implement the message handlers and talk about how to host, configure, and run a NSB instance.&lt;br /&gt;&lt;br /&gt;Code can be found &lt;a href="http://github.com/afyles/Blog/tree/master/MvcMusicStore-v0.8/"&gt;HERE&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-1042957872173214020?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/1042957872173214020/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2010/08/getting-started-with-nservicebus-part-2_25.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/1042957872173214020'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/1042957872173214020'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2010/08/getting-started-with-nservicebus-part-2_25.html' title='Getting Started with NServiceBus Part 3: Putting Messages on the Bus'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-456033111800421199</id><published>2010-08-18T11:13:00.000-07:00</published><updated>2010-08-24T12:57:52.641-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><title type='text'>Getting Started with NServiceBus Part 2: Music Store Schema</title><content type='html'>Now that we've identified our architecture, the next order of business is to identify what information will be shared within the system. &amp;nbsp;In our example we will be sending commands to the server to update shopping carts and to place orders. &amp;nbsp;We'll need two classes to house that information. &amp;nbsp;First we'll take a look into adding something to a cart by looking at the ShoppingCartController class. &amp;nbsp;We quickly find the add method:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:c#"&gt;&amp;nbsp;public ActionResult AddToCart(int id)&lt;br /&gt;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cart.AddToCart(addedAlbum);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;br /&gt;&amp;nbsp;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This leads us to the AddToCart method:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:c#"&gt;&amp;nbsp;public void AddToCart(Album album)&lt;br /&gt;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (cartItem == null)&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Create a new cart item&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cartItem = new Cart&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AlbumId = album.AlbumId,&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CartId = shoppingCartId,&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Count = 1,&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DateCreated = DateTime.Now&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;};&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;storeDB.AddToCarts(cartItem);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Add one to the quantity&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cartItem.Count++;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Save it&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;storeDB.SaveChanges();&lt;br /&gt;&amp;nbsp;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;We find that all we need is the id of the album and the id of the cart to add it to, and therefore we can define our command as:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:c#"&gt;public interface IAddToCartCommand : ICommand&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;String CartId { get; set; }&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Int32 AlbumId { get; set; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public interface ICommand : IMessage&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;In order to share the reference to the Cart class we have to pull the Models namespace into a separate assembly out of the uber assembly the sample ships with. &amp;nbsp;There are three major things to note in this code. &lt;br /&gt;&lt;br /&gt;First of all in order to identify a message to the NServiceBus infrastructure, we must mark the message with the IMessage interface. &amp;nbsp;This is how NSB will wire messages to message handlers. &lt;br /&gt;&lt;br /&gt;The second note is that we've created an intermediary interface. &amp;nbsp;We have done this so we can easily differentiate between commands and events. &amp;nbsp;Commands denote one-way, point to point communication between known parties. &amp;nbsp;Events denote one-way, one to many communication with potentially unknown parties. &amp;nbsp;The other way we differentiate the two is to change how the verb in the name is used. &amp;nbsp;Typically commands will tell the server to do something, ex. "AddToCart". &amp;nbsp;An event will let us know something happened in the past, ex. "ItemAddedToCart". &lt;br /&gt;&lt;br /&gt;Lastly we always use interfaces to define our message schema. &amp;nbsp;If we do so then NSB can gracefully handle the versioning of messages for us. &amp;nbsp;This becomes very important when we change our messages and we have to maintain backwards&amp;nbsp;compatibility.&lt;br /&gt;&lt;br /&gt;Now we can look at placing an order. &amp;nbsp;The code for this is a bit strange as its broken up into two different transactions, one for the "header" and one for the details. &amp;nbsp;The first part is in the AddressAndPayment method in the CheckoutController class, and the second part is in the ShoppingCart class:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:c#"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public ActionResult AddressAndPayment(FormCollection values)&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var order = new Order();&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;order.Username = User.Identity.Name;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;order.OrderDate = DateTime.Now;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//Save Order&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;storeDB.AddToOrders(order);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;storeDB.SaveChanges();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//Process the order&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var cart = ShoppingCart.GetCart(this.HttpContext);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cart.CreateOrder(order);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return RedirectToAction("Complete",&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;new { id = order.OrderId });&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ...&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;public int CreateOrder(Order order)&lt;br /&gt;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var cartItems = GetCartItems();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;foreach (var cartItem in cartItems)&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var orderDetails = new OrderDetail&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AlbumId = cartItem.AlbumId,&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;OrderId = order.OrderId,&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;UnitPrice = cartItem.Album.Price&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;};&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;storeDB.OrderDetails.AddObject(orderDetails);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//Save the order&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;storeDB.SaveChanges();&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//Return the OrderId as a confirmation number&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return order.OrderId;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;In order to preserve consistency in our database, we'll perform all these actions in a single transaction. &amp;nbsp;This way we don't get orders without their details. &amp;nbsp;Also by using durable messaging, we'll ensure that orders don't get lost. &amp;nbsp;Within the code, the Order is constructed from the ShoppingCart object. &amp;nbsp;Therefore, all we need is the id of the current cart, and we can look up the rest of the information server side(also reducing trips to the server):&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:c#"&gt;public interface IPlaceOrderCommand : ICommand&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;String CartId { get; set; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In summary we've decided on how our schema is going to look so that we can now start putting these messages On the Bus! &amp;nbsp;Next time we'll change the store front to put messages on the bus. &amp;nbsp;Code can be found &lt;a href="http://github.com/afyles/Blog/tree/master/MvcMusicStore-v0.8/"&gt;here&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-456033111800421199?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/456033111800421199/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2010/08/getting-started-with-nservicebus-part-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/456033111800421199'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/456033111800421199'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2010/08/getting-started-with-nservicebus-part-2.html' title='Getting Started with NServiceBus Part 2: Music Store Schema'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-2329586751739307373</id><published>2010-08-14T09:33:00.001-07:00</published><updated>2010-08-14T09:33:46.764-07:00</updated><title type='text'>NServiceBus for Admins Slide Deck</title><content type='html'>I've used this deck to introduce NSB to Admins and help them understand the key components of the infrastructure.  The deck highlights what they will be responsible for and how to configure the infrastructure for NSB.  There are a few slides that have imagery for the NSB site, so I attribute full credit to them for those slides.&lt;div style="width:425px" id="__ss_4969839"&gt;&lt;strong style="display:block;margin:12px 0 4px"&gt;&lt;a href="http://www.slideshare.net/afyles/nservicebusforadmins" title="NServiceBus_for_Admins"&gt;NServiceBus_for_Admins&lt;/a&gt;&lt;/strong&gt;&lt;object id="__sse4969839" width="425" height="355"&gt;&lt;param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=nservicebusforadmins-plain-100814112737-phpapp01&amp;stripped_title=nservicebusforadmins" /&gt;&lt;param name="allowFullScreen" value="true"/&gt;&lt;param name="allowScriptAccess" value="always"/&gt;&lt;embed name="__sse4969839" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=nservicebusforadmins-plain-100814112737-phpapp01&amp;stripped_title=nservicebusforadmins" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div style="padding:5px 0 12px"&gt;View more &lt;a href="http://www.slideshare.net/"&gt;presentations&lt;/a&gt; from &lt;a href="http://www.slideshare.net/afyles"&gt;afyles&lt;/a&gt;.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-2329586751739307373?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/2329586751739307373/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2010/08/nservicebus-for-admins-slide-deck.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/2329586751739307373'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/2329586751739307373'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2010/08/nservicebus-for-admins-slide-deck.html' title='NServiceBus for Admins Slide Deck'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-5865237884807475460</id><published>2010-08-14T09:18:00.000-07:00</published><updated>2010-08-17T05:15:41.729-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><category scheme='http://www.blogger.com/atom/ns#' term='CQRS'/><title type='text'>Getting Started with NServiceBus Part 1: Analysis of ASP.NET MVC Music Store</title><content type='html'>In part one of our series we'll begin by analyzing the current state of our application. &amp;nbsp;I've chosen the &lt;a href="http://mvcmusicstore.codeplex.com/"&gt;ASP.NET MVC Music Store&lt;/a&gt; as my example as it has a very small feature set. &amp;nbsp;What we have is a very simple store front application where you can browse and purchase albums. &amp;nbsp;The application is your atypical web application that is entirely dependent on a Request/Response architecture. &amp;nbsp;There are a few places within the application where Request/Response may pose some challenges.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The Shopping Cart&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Currently the application pushes a record to the database for each item in your cart. &amp;nbsp;As a user you really don't know this is happening until something goes wrong. &amp;nbsp;If for some reason the supporting database was no longer available, the user would not be able to add items to the cart. &amp;nbsp;Some may say that you have larger issues in that if the database is down, the whole site is down. &amp;nbsp;For our purposes let's pretend we cache all our static content on a CDN somewhere and we can still browse albums. &amp;nbsp;To keep our users filling there carts, we'll push a message to the server and update the database in a separate process altogether.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Checking Out&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;This feature works the same as the Shopping Cart, the user enters their information and their order is pushed to the database. &amp;nbsp;We have the same potential issue here, if we cannot accept orders our music store is not making us money. &amp;nbsp;We'd also hate to make a user who has a large order submit it all over again. &amp;nbsp;We're really concerned with 2 things here, making the customer happy and making sure the store is taking orders. &amp;nbsp;We'll take the same approach as above and push messages to the server and subsequently update the database. &amp;nbsp;Now the customers will be happy and we won't lose orders.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Architecture&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;To accomplish all of this we'll use NServiceBus to move messages to the server and process them. &amp;nbsp;We'll device a way to plug NSB into the ASP.NET runtime so we can send messages from the web application. &amp;nbsp;Next we'll create a NSB host on our server to handle the carts and the orders.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Summary&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;We'll found a couple of soft spots in our application where we can apply messaging to make the customer happy and keep the store running. &amp;nbsp;Next time we'll start to apply NSB to our solution and walk through the basics of configuring the web application to send messages.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-5865237884807475460?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/5865237884807475460/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2010/08/on-bus-part-1-analysis-of-aspnet-mvc.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/5865237884807475460'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/5865237884807475460'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2010/08/on-bus-part-1-analysis-of-aspnet-mvc.html' title='Getting Started with NServiceBus Part 1: Analysis of ASP.NET MVC Music Store'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-4172790054840245318</id><published>2010-08-09T17:06:00.000-07:00</published><updated>2010-08-09T17:06:32.829-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><title type='text'>NServiceBus - What did I just download?</title><content type='html'>I'm currently working on getting some teams in my organization On the Bus and I find myself often quickly explaining what you get when you download NSB. &amp;nbsp;It includes so much functionality that it helps to quickly dissect what is there. &amp;nbsp;I'm going to lay it out at a high level so we all know what's in there and where to go first.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Root Directory&lt;/b&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_sC2VEzP-9qE/TGCRBCAZEYI/AAAAAAAAA1A/ukedjNs4Aeg/s1600/nservice_bus_download.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_sC2VEzP-9qE/TGCRBCAZEYI/AAAAAAAAA1A/ukedjNs4Aeg/s320/nservice_bus_download.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;The top level directory is pretty self explanatory, I'm going to jump right into the first level of directories and start the tour there.&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;b&gt;Binaries&lt;/b&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_sC2VEzP-9qE/TGCRY4jNRgI/AAAAAAAAA1I/NMn_rq4zrSE/s1600/nservice_bus_download_binaries.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_sC2VEzP-9qE/TGCRY4jNRgI/AAAAAAAAA1I/NMn_rq4zrSE/s320/nservice_bus_download_binaries.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;This directory contains the bare bones to run NSB. &amp;nbsp;The exe is the Generic Host provided with NSB. &amp;nbsp;This gives us a process to run NSB inside of. &amp;nbsp;The only other assemblies you really need to run basic NSB functionality is NServiceBus.Core, NServiceBus, and log4net. &amp;nbsp;The rest will depend on your use case. &amp;nbsp;The "containers" directory has the binaries for the container of your choice, you don't have to use the default container(Spring). &amp;nbsp;The "x64" directory has the x64 version of SQLite for testing purposes.&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;b&gt;Docs&lt;/b&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_sC2VEzP-9qE/TGCSUA9mD1I/AAAAAAAAA1Q/FdwZPhRj0SI/s1600/nservice_bus_download_docs.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_sC2VEzP-9qE/TGCSUA9mD1I/AAAAAAAAA1Q/FdwZPhRj0SI/s320/nservice_bus_download_docs.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;The "docs" directory has some slides and diagrams of some of the functionality included with NSB, more on these later. &amp;nbsp;It also has some common code snippets for Visual Studio. &amp;nbsp;Don't expect deep dive information in the slides, they are just pictures at this point.&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;b&gt;Processes&lt;/b&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_sC2VEzP-9qE/TGCSxouuWrI/AAAAAAAAA1Y/Rwlow7lDy50/s1600/nservice_bus_download_processes.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_sC2VEzP-9qE/TGCSxouuWrI/AAAAAAAAA1Y/Rwlow7lDy50/s320/nservice_bus_download_processes.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;The "processes" directory contains some NSB infrastructure that you'll need for certain NSB use cases. &amp;nbsp;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;"distributor" - contains the background process for distributing load across many instances of NSB. &amp;nbsp;This process handles monitoring the work load and distributing the work to worker nodes.&lt;/li&gt;&lt;li&gt;"gateway" - contains the process that manages moving messages between disparate instances of NSB. This is especially useful if you have more that one data center. &amp;nbsp;You can move messages between sites using the gateway.&lt;/li&gt;&lt;li&gt;"proxy" - this process allows us to expose a single endpoint to several clients. &amp;nbsp;This is handy when you need to expose NSB through a firewall.&lt;/li&gt;&lt;li&gt;"timeout" - this process handles the watching of the clock for Sagas. &amp;nbsp;Sagas are analogous to long running workflows. &amp;nbsp;When using Sagas, you need something to keep a watch and wait up workflows when necessary.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;b&gt;Samples&lt;/b&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_sC2VEzP-9qE/TGCUK-3t18I/AAAAAAAAA1g/X3ALZM5n-pY/s1600/nservice_bus_downloads_samples.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_sC2VEzP-9qE/TGCUK-3t18I/AAAAAAAAA1g/X3ALZM5n-pY/s320/nservice_bus_downloads_samples.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;"AsyncPages" - example of how to due asynchronous request/response on a web page using ASP.NET as your host process.&amp;nbsp;&lt;/li&gt;&lt;li&gt;"FullDuplex" - example of performing request/response in a non-web scenario&lt;/li&gt;&lt;li&gt;"GenericHost" - example of how the host provided with NSB works. &amp;nbsp;Via the concept of profiles we can manipulate the behaviour of the host.&lt;/li&gt;&lt;li&gt;"Manufacturing" - this example has a lot of stuff in it, including Pub/Sub, Sagas, interop with straight MSMQ, the included testing framework, message ordering, and more. &amp;nbsp;I found myself taking bits of this example and breaking it down into smaller examples.&lt;/li&gt;&lt;li&gt;"PubSub" - basic example of how to implement the Publish/Subscribe pattern in NSB.&lt;/li&gt;&lt;li&gt;"Versioning" - shows how that through interfaces, NSB allows us to gracefully version messages to consumers without breaking them.&lt;/li&gt;&lt;li&gt;"WcfIntegration" - shows off the OOTB support for exposing NSB as a HTTP/WCF service. &amp;nbsp;This becomes useful if you have to interact with another non-MSMQ system.&lt;/li&gt;&lt;li&gt;"WebServiceBridge" - hosts NSB from within ASP.NET again, only this time in a web service. &amp;nbsp;The web site in this sample using the service to bridge into NSB without knowing about NSB itself.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;b&gt;Tools&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_sC2VEzP-9qE/TGCWkkMQnEI/AAAAAAAAA1o/CLfqI0A9znM/s1600/nservice_bus_download_tools.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_sC2VEzP-9qE/TGCWkkMQnEI/AAAAAAAAA1o/CLfqI0A9znM/s320/nservice_bus_download_tools.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;"MsmqUtils" - provides a program for you to run to validate your install of MSMQ and MSDTC. &amp;nbsp;This is a handy tool to make sure you start off on the right foot, I recommend running this right after you download NSB to avoid headaches.&lt;/li&gt;&lt;li&gt;"ReturnToSourceQueue.exe" - takes messages from a queue(typically an error queue) and pushes them back to the source queue. &amp;nbsp;This tool is very effective when you have a bunch of failures that you want to re-process. &amp;nbsp;I would make sure your SysAdmins know about this tool.&lt;/li&gt;&lt;li&gt;"UI.exe" - is a limited UI for managing NSB endpoints.&lt;/li&gt;&lt;li&gt;"XsdGenerator.exe" - this tool will generate an XSD file using an assembly of messages as input. &amp;nbsp;This is for the case where you don't want to directly distribute your messages assembly, but would rather have consumers build their own.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div&gt;That pretty much covers it, there is a lot of stuff in here! &amp;nbsp;I'm hoping to next start talking about some of the use cases we've had to leverage NSB and get started on a demo project to walk through an application of NSB.&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-4172790054840245318?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/4172790054840245318/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2010/08/nservicebus-what-did-i-just-download.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/4172790054840245318'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/4172790054840245318'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2010/08/nservicebus-what-did-i-just-download.html' title='NServiceBus - What did I just download?'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_sC2VEzP-9qE/TGCRBCAZEYI/AAAAAAAAA1A/ukedjNs4Aeg/s72-c/nservice_bus_download.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-4487625910404778189</id><published>2010-08-09T13:29:00.000-07:00</published><updated>2010-08-09T13:29:04.848-07:00</updated><title type='text'>Installing NServiceBus Using the Network Service Account</title><content type='html'>Our defacto standard for Windows Services is to install under the "Network Service" account or "MachineName$".  To get NSB to install under this account, I had to try several variations of the account name and finally it came down to using a fully qualified name:&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;nservicebus.host.exe /install /serviceName:"ServiceName" /displayName:"DisplayName" /userName:"NT AUTHORITY\Network Service" /password:""&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-4487625910404778189?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/4487625910404778189/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2010/08/installing-nservicebus-using-network.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/4487625910404778189'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/4487625910404778189'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2010/08/installing-nservicebus-using-network.html' title='Installing NServiceBus Using the Network Service Account'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-4067034546408222655</id><published>2010-08-06T08:41:00.000-07:00</published><updated>2010-08-06T09:04:58.207-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='REST'/><category scheme='http://www.blogger.com/atom/ns#' term='NServiceBus'/><title type='text'>Exposing NServiceBus as a REST(WCF) Endpoint</title><content type='html'>&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I recently had a situation where I wanted to expose NSB as a REST endpoint. &amp;nbsp;WCF hosting comes out of the box with NSB, but it defaults to an HTTP binding. &amp;nbsp;Normally it would be a problem to just add another endpoint via config, but when using the webHttpBinding in WCF we need the ability to decorate operations with some attributes which is not configurable in a config file. &amp;nbsp;Luckily for us, NSB gives us a simple extension point to wire in our own ServiceHost. &amp;nbsp;I started by creating my WCF contract:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;pre class="brush:c#"&gt;[ServiceContract]&lt;br /&gt;    public interface IProductCreatedRestService&lt;br /&gt;    {&lt;br /&gt;        [OperationContract]&lt;br /&gt;        [WebInvoke(UriTemplate = "products", RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml)]&lt;br /&gt;        void Create(ProductCreatedMessage message);&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;Next up is the concrete implementation:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;pre class="brush:c#"&gt;[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public class ProductCreatedRestService : IProductCreatedRestService&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;private readonly IBus bus;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public ProductCreatedRestService()&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if ( null == this.bus )&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;this.bus = Configure.Instance.Builder.Build&amp;lt;IBus&amp;gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public void Create(ProductCreatedMessage message)&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;this.bus.Send(message);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;The big note here is that I'm building an instance of IBus using the NSB IoC container. An alternative would be to register the component at startup and let NSB property-inject IBus. The next thing I need to do is create and open up a WebServiceHost for my service. I do this via the IWantToRunAtStartup marker interface. NSB makes heavy use of the marker interface pattern. This allows it to identify certain classes via the IoC container. This interface let's us plugin our own custom code when NSB starts up and subsequently shuts down. Here is my startup class:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;pre class="brush:c#"&gt;&amp;nbsp;public class RestServiceStartup : IWantToRunAtStartup&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;private WebServiceHost host;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public void Run()&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;this.host = new WebServiceHost(typeof(ProductCreatedRestService));&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;this.host.Open();&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public void Stop()&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (null != this.host &amp;amp;&amp;amp; this.host.State == System.ServiceModel.CommunicationState.Opened)&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;this.host.Close();&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;My handler for the message is standard issue NSB fare:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;pre class="brush:c#"&gt;&amp;nbsp;public void Handle(ProductCreatedMessage message)&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Normally you would do a Bus.Send here first&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (message.ProductNumber == 1111)&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;this.Bus.Return((Int32)CommandErrorCodes.Fail);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;this.Bus.Return((Int32)CommandErrorCodes.Success);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;Now we can fire up our NSB instance and also jump into Fiddler to generate our request:&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_sC2VEzP-9qE/TFwl-s40hMI/AAAAAAAAA04/6qPrYUwWvTs/s1600/nsb_rest_fiddler.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="472" src="http://1.bp.blogspot.com/_sC2VEzP-9qE/TFwl-s40hMI/AAAAAAAAA04/6qPrYUwWvTs/s640/nsb_rest_fiddler.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-4067034546408222655?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/4067034546408222655/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2010/08/exposing-nservicebus-as-restwcf.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/4067034546408222655'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/4067034546408222655'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2010/08/exposing-nservicebus-as-restwcf.html' title='Exposing NServiceBus as a REST(WCF) Endpoint'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_sC2VEzP-9qE/TFwl-s40hMI/AAAAAAAAA04/6qPrYUwWvTs/s72-c/nsb_rest_fiddler.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-288124269083996844.post-669452795227055472</id><published>2010-08-06T07:20:00.000-07:00</published><updated>2010-08-06T07:20:51.510-07:00</updated><title type='text'>Seminal Post</title><content type='html'>Hey all the plan is to post some interesting things I've come across while working with &lt;a href="http://nservicebus.com/"&gt;NServiceBus&lt;/a&gt;. &amp;nbsp;I plan on launching a full on demo project in the very near future. &amp;nbsp;I need to find someplace to host my code(suggestions welcome) and also pick a pet project to modify. &amp;nbsp;I'm thinking of taking a bite from Ayende's plate and using the ASP.NET MVC sample project. &amp;nbsp;Stay tuned...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/288124269083996844-669452795227055472?l=adamfyles.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://adamfyles.blogspot.com/feeds/669452795227055472/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://adamfyles.blogspot.com/2010/08/seminal-post.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/669452795227055472'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/288124269083996844/posts/default/669452795227055472'/><link rel='alternate' type='text/html' href='http://adamfyles.blogspot.com/2010/08/seminal-post.html' title='Seminal Post'/><author><name>Adam Fyles</name><uri>http://www.blogger.com/profile/04954291460807548462</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='http://4.bp.blogspot.com/_sC2VEzP-9qE/TSOvBPrOY2I/AAAAAAAAA20/zbcZujPm2gs/S220/IMAG0062.jpg'/></author><thr:total>0</thr:total></entry></feed>
