<?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-1942748161021467080</id><updated>2011-07-28T20:28:34.823-03:00</updated><category term='c#'/><category term='.net'/><category term='rhino'/><category term='MessageBus'/><title type='text'>IllDev</title><subtitle type='html'>A remote notebook</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://illdev.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1942748161021467080/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://illdev.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Jan</name><uri>http://www.blogger.com/profile/04294418393369661860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_SKmxBuw1bL4/S8TajOpikQI/AAAAAAAAC4k/-9TfGE8HW_s/s1600-R/52dc0db2cdacc6e9769d074a37466317.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1942748161021467080.post-384367435618246684</id><published>2010-09-03T21:59:00.001-03:00</published><updated>2010-09-03T21:59:38.190-03:00</updated><title type='text'>Rhino Commons and Nhibernate Fluent with NHibernate 3 alpha 2</title><content type='html'>&lt;div class='posterous_autopost'&gt;Can be downloaded from github&lt;p /&gt;&lt;a href="http://github.com/janlimpens/rhino-commons"&gt;http://github.com/janlimpens/rhino-commons&lt;/a&gt; and&lt;br /&gt;&lt;a href="http://github.com/janlimpens/fluent-nhibernate"&gt;http://github.com/janlimpens/fluent-nhibernate&lt;/a&gt;&lt;p /&gt; on rhino side not all tests pass, but this is more due to config/permission issues than due to actual code. I knew, I already patched these places in the past. It just sucks, that I cannot find these patches anymore.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1942748161021467080-384367435618246684?l=illdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://illdev.blogspot.com/feeds/384367435618246684/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1942748161021467080&amp;postID=384367435618246684&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1942748161021467080/posts/default/384367435618246684'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1942748161021467080/posts/default/384367435618246684'/><link rel='alternate' type='text/html' href='http://illdev.blogspot.com/2010/09/rhino-commons-and-nhibernate-fluent.html' title='Rhino Commons and Nhibernate Fluent with NHibernate 3 alpha 2'/><author><name>Jan</name><uri>http://www.blogger.com/profile/04294418393369661860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_SKmxBuw1bL4/S8TajOpikQI/AAAAAAAAC4k/-9TfGE8HW_s/s1600-R/52dc0db2cdacc6e9769d074a37466317.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1942748161021467080.post-5524771596999233347</id><published>2010-08-23T21:40:00.001-03:00</published><updated>2010-08-23T21:40:34.141-03:00</updated><title type='text'>Log a user's session</title><content type='html'>&lt;div class='posterous_autopost'&gt;Websites always have bugs, there is no way around it. Too many different components come into play.&lt;br /&gt;There is&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Different browsers&lt;/li&gt;&lt;li&gt;Different user implementations (at some level) like authenticated users and unauthenticated ones, preferred customers and blocked customers&lt;br /&gt; &lt;/li&gt;&lt;li&gt;Different paths to do things&lt;/li&gt;&lt;li&gt;Different layers where exceptions can happen and different implementations how these are communicated back to the origin&lt;/li&gt;&lt;li&gt;and many more I cannot think of right now&lt;br /&gt;&lt;/li&gt; &lt;/ul&gt;all these potential fallacies form a Cartesian product of terror. To the website owner as well as to the developer. One can log these errors, but logging often does not show the context of the error and this makes logging not quite useless, but not as useful as one would wish for.&lt;p /&gt; So to make logging meaningful I would want it to be contextual. How can this be done? My take is, that I need to log a whole user session, from the fist hit to the last, keeping only logs with exceptions in it.&lt;p /&gt; This implies, that I must uniquely identify each user session. The session id could provide such an id for unauthenticated users, username + session id for authenticated ones. But this makes us imply that sessions do not get lost and recreated. So maybe a cookie then: let&amp;#39;s store a cookie with the session id in it and short expiration at session begin and check if that cookie exists, if another session is created. If there is such a cookie, we know we are dropping sessions and can log this.&lt;p /&gt; Then we can have sessions without exceptions that just expired. The user lost interest. While this can be of interest to somebody, it is not my concern. I would want to delete that logging. Or we have a successful session. In my case, the user made a complete purchase and there were no exceptions in his session. I want to delete those as well.&lt;p /&gt; I want to keep these logs isolated from each other, so I will persist them individually. For cross concern logging traditional log files are better suited. There are also different classes of exceptions like SQL timeouts, that usually don&amp;#39;t have anything to do with specific users, but I would not want to have a black/white list of exceptions to log. For now at least.&lt;p /&gt; File layout: /logfiles/day/username+cookie-id&lt;p /&gt;I keep a dictionary cookie id / kill-time (cookie expiry date), every further hit, bumps up kill time and cookie expiry, an exception removes the item from the list entirely, so that it will not be deleted. Now I only need to have somebody check this dictionary in regular instances and delete files with a kill time &amp;lt; now.&lt;p /&gt; In the file I want to log every step the user makes with &lt;br /&gt;&lt;ol&gt;&lt;li&gt;time&lt;br /&gt;&lt;/li&gt;&lt;li&gt;url&lt;br /&gt;&lt;/li&gt;&lt;li&gt;parameters (query string gets, posts, cookie and session values)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;referrer&lt;/li&gt;&lt;li&gt;eventual problems&lt;/li&gt; &lt;li&gt;exception&lt;/li&gt;&lt;/ol&gt;Probably a html table would make for an easily readable format.&lt;p /&gt;Luckily the castle stack I am using allows me to have a single place for attaching this logging behaviour. So I am looking forward into implementing this. Just me thinking out loud.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1942748161021467080-5524771596999233347?l=illdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://illdev.blogspot.com/feeds/5524771596999233347/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1942748161021467080&amp;postID=5524771596999233347&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1942748161021467080/posts/default/5524771596999233347'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1942748161021467080/posts/default/5524771596999233347'/><link rel='alternate' type='text/html' href='http://illdev.blogspot.com/2010/08/log-user-session.html' title='Log a user&amp;#39;s session'/><author><name>Jan</name><uri>http://www.blogger.com/profile/04294418393369661860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_SKmxBuw1bL4/S8TajOpikQI/AAAAAAAAC4k/-9TfGE8HW_s/s1600-R/52dc0db2cdacc6e9769d074a37466317.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1942748161021467080.post-5345361166935291907</id><published>2010-04-12T17:23:00.000-03:00</published><updated>2010-04-13T18:00:25.813-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.net'/><category scheme='http://www.blogger.com/atom/ns#' term='MessageBus'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><category scheme='http://www.blogger.com/atom/ns#' term='rhino'/><title type='text'>Building a message bus style app</title><content type='html'> &lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre{ font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em;}.csharpcode .lnum { color: #606060; }&lt;/style&gt;  &lt;blockquote&gt; &lt;p&gt;Warning: One of the main motivations for me to write this entry was the lack of anything to read about Rhino.ServiceBus (Rhino.ESB for some). But as much as I wished I was, I am no authority on the subject and you should not expect much more from reading this than to get some hints that help you avoid the most frustrating pitfalls.&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;I recently inherited a semi abandoned project, that uses the message bus paradigm, one I have not used in the past. There are tests and they run, but when I try to run things in my application, I have a few problems.&lt;/p&gt; &lt;ol&gt; &lt;li&gt;I cannot figure out how to run this as a service (and not in the context of the application)&lt;/li&gt; &lt;li&gt;I have absurd resource usage.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;The project uses Rhino.ServiceBus, which has &lt;/p&gt; &lt;ul&gt; &lt;li&gt;very good code quality as it was written by &lt;a href="http://ayende.com/Blog"&gt;Ayende Rahien&lt;/a&gt; and &lt;/li&gt; &lt;li&gt;hardly any community behind it and &lt;/li&gt; &lt;li&gt;no documentation at all. &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;I do not overly like with Rhino.Bus that it creates a hard dependency on Castle.Windsor and the lack of community could mean one day that I will have to maintain a private fork of the project, just as I am already doing with rhino.commons. As far as I know it is far easier to setup and use than other busses, so this could mean a big plus.&lt;/p&gt; &lt;p&gt;You can download Rhino.ServiceBus &lt;a href="http://github.com/ayende/rhino-esb"&gt;here&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;So, first I actually want to understand, how this whole bus shtick is working, without having to take care about my app. From what I can gather bus architectures are about decoupling systems by exchanging simple poco messages. A good read on the subject I found &lt;a href="http://msdn.microsoft.com/en-us/library/ms978583.aspx"&gt;there&lt;/a&gt;. So I'll create an app that does just that.&lt;/p&gt; &lt;p&gt;First I want to do something simple and very 'messagey', not using any database persistence: sending a email like message and have a service handle that (probably by sending it as an email message). I want the client app to be completely ignorant of the service and have both communicate only via the message bus (encapsulated by Rhino.ServiceBus).&lt;/p&gt; &lt;p&gt;So, first I create a class for the communication to occur:&lt;/p&gt;&lt;pre class="csharpcode"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; SendMessage
  {
      &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; [] Recipients { get; set; }
      &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Sender { get; set; }
      &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Title { get; set; }
      &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Body { get; set; }
  }&lt;/pre&gt;
&lt;p&gt;Looks like a MailMessage, probably I could use that one, too, but that would tie my model to the purpose of email sending. I might want to have different endpoints not involving email sending. What the hell, I am just making this up to get some grip on some infrastructure.&lt;/p&gt;
&lt;p&gt;I create a MVC sample app with a basic html form similar to the message and in the controller &lt;/p&gt;&lt;pre class="csharpcode"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; ActionResult Send(&lt;span class="kwrd"&gt;string&lt;/span&gt; sender, &lt;span class="kwrd"&gt;string&lt;/span&gt; rcpt, &lt;span class="kwrd"&gt;string&lt;/span&gt; subject, &lt;span class="kwrd"&gt;string&lt;/span&gt; body)
      {
          var msg = &lt;span class="kwrd"&gt;new&lt;/span&gt; SendMessage
                      {
                          Sender = sender,
                          Recipients = &lt;span class="kwrd"&gt;new&lt;/span&gt;[] { rcpt },
                          Title = subject,
                          Body = body
                      };

          fireAndForget(msg);
          ViewData[&lt;span class="str"&gt;"Message"&lt;/span&gt;] = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;"Message sent to {0}."&lt;/span&gt;, rcpt);
          &lt;span class="kwrd"&gt;return&lt;/span&gt; View();
      }&lt;/pre&gt;
&lt;p&gt;So far nothing unusual. Usually, I'd use Castle.Windsor to get me an IEmailSender service and invoke that in the controller method, but I do not want to do that here. Instead I use that fireAndForget method.&lt;/p&gt;
&lt;p&gt;Let's see, how I can implement that... I have been playing around with Rhino.ServiceBus a bit, so I already got an idea of how to go about this (but I am not sure if it's the right path. Part of why I am writing all this is to maybe get some good imput on how to do it better or right at all). Rhino.ServiceBus uses Castle.Windsor for IOC, so do I. I guess the easiest route is to go with that.&lt;/p&gt;
&lt;p&gt;I find out how to use asp.net MVC with Castle.... ok, this is now done. Quite easy.&lt;/p&gt;
&lt;p&gt;I called my sending method fireAndForget, because that's how a web app can use messaging. You usually cannot wait for the bus to return anything, so just cross your fingers and be done with it. Validation becomes more important that way, probably...&lt;/p&gt;
&lt;p&gt;There are different types of 'bus' implementations here ('bus' means the client part here, you use those for actively making use of the bus, opposed to the various host types, which are the headless robots you annoy with all your messages and make them work on your behalf):&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;DefaultServiceBus 
&lt;li&gt;OnewayBus&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;The difference probably is that 1 is for stateful apps where the dialog between you and the 'bus' is bidirectional, and 2 is a stateless version I am using here. I am starting to get a feeling that what is puzzling me most here, is, that the term 'bus' means a lot of different things...&lt;/p&gt;
&lt;p&gt;To be able to make use of the OneWayBus, I need to register this:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;/pre&gt;
&lt;p&gt;container.Kernel.AddFacility(&lt;span class="str"&gt;"OnewayRhinoServiceBusFacility"&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; OnewayRhinoServiceBusFacility());&lt;/p&gt;
&lt;p&gt;So I have a look what this is actually doing... &lt;/p&gt;&lt;pre class="csharpcode"&gt;        &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Init()
      {
          &lt;span class="kwrd"&gt;new&lt;/span&gt; MessageOwnersConfigReader(FacilityConfig, messageOwners).ReadMessageOwners();


          Kernel.Register(
              Component.For&amp;lt;IMessageBuilder&amp;gt;()
                  .LifeStyle.Is(LifestyleType.Singleton)
                  .ImplementedBy&amp;lt;MessageBuilder&amp;gt;(),
              Component.For&amp;lt;IOnewayBus&amp;gt;()
                  .LifeStyle.Is(LifestyleType.Singleton)
                  .ImplementedBy&amp;lt;OnewayBus&amp;gt;()
                  .DependsOn(&lt;span class="kwrd"&gt;new&lt;/span&gt;{messageOwners = messageOwners.ToArray()}),
              Component.For&amp;lt;IReflection&amp;gt;()
                  .LifeStyle.Is(LifestyleType.Singleton)
                  .ImplementedBy&amp;lt;DefaultReflection&amp;gt;(),
              Component.For&amp;lt;IMessageSerializer&amp;gt;()
                  .LifeStyle.Is(LifestyleType.Singleton)
                  .ImplementedBy(serializerImpl),
              Component.For&amp;lt;IEndpointRouter&amp;gt;()
                   .ImplementedBy&amp;lt;EndpointRouter&amp;gt;()
              );
      }&lt;/pre&gt;
&lt;p&gt;I can be sure there will be quite a need for configuration here... Bad luck with the samples. Nothing uses OneWayBus... let's see what my halfway implemented project has... &lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;="1.0"&lt;/span&gt;?&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;configuration&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;facilities&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;facility&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="rhino.owb"&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;messages&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;add&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="BusTest.Messages"&lt;/span&gt;
           &lt;span class="attr"&gt;endpoint&lt;/span&gt;&lt;span class="kwrd"&gt;="msmq://localhost/BusTest"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;messages&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;facility&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;facilities&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;configuration&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;I was lucky, something was there! I found in rhinos code that the name attribute refers to the namespace your messages are in. The queue endpoint URI I just made up.&lt;/p&gt;
&lt;p&gt;So finally my fireAndForget() looks like this:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; fireAndForget(&lt;span class="kwrd"&gt;object&lt;/span&gt; msg)
{
  _bus.Send(msg);
}&lt;/pre&gt;
&lt;p&gt;let’s see what happens if I run that. Seems to work, but…&lt;/p&gt;&lt;pre class="csharpcode"&gt;The queue msmq://devrig/BusTest does not exists&lt;/pre&gt;
&lt;p&gt;So let’s see what Ayende does about this in his samples… ok I just steal his PrepareQueues class from the Starbucks sample, add a Reference to System.Messaging and see, if setting up the queue with it will make the app happier (probably).&lt;/p&gt;
&lt;p&gt;Ok, seems to have worked. Of course that poor message now fell into a world of boredom, because there is nobody doing anything with it. Let’s see if I can find it in the Console (/Start/Administrative Tools/Computer Management/Services and Applications/Message Queuing/Private Queues) and there it is!&lt;/p&gt;
&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_SKmxBuw1bL4/S8N6pde-l8I/AAAAAAAAC4Y/gedg2SPDhTc/s1600-h/image%5B2%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_SKmxBuw1bL4/S8N6qS_TjLI/AAAAAAAAC4c/9c7sv2awbfg/image_thumb.png?imgmax=800" width="220" height="244"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;I only wish I knew, where I actually can find the message physically. If something goes wrong, having to check the message in this stupid property dialog would make things only worse.&lt;/p&gt;
&lt;p&gt;Now, this was not as easy as it looks now. But after quite a few trials and error and a few weeks of trying to get my head around the ideas of message busses and how one would work with it, banging my head on the table and crying for help at forums, I finally got some understanding that helps greatly now :)&lt;/p&gt;
&lt;p&gt;Ok, second half of the task: consume this message somehow (do something with it).&lt;/p&gt;
&lt;p&gt;I create a new project (dll) and put this class in it:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; SendMessageService : ConsumerOf&amp;lt;SendMessage&amp;gt;
{
  &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Consume(SendMessage message)
  {
      var msg = &lt;span class="kwrd"&gt;new&lt;/span&gt; MailMessage
                  {
                      From = &lt;span class="kwrd"&gt;new&lt;/span&gt; MailAddress(message.Sender),
                      Subject = message.Title,
                      Body = message.Body
                  };
      message.Recipients.Select(r =&amp;gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; MailAddress(r)).ToList().ForEach(msg.To.Add);
      var client = &lt;span class="kwrd"&gt;new&lt;/span&gt; SmtpClient();
      client.Send(msg);
  }
}&lt;/pre&gt;
&lt;p&gt;This should handle the task nicely. Now I need to host this service somewhere where it will be invoked in the event of an arriving SendMessage message. If you build Rhino.ServiceBus you will find a &lt;strong&gt;Rhino.ServiceBus.Host.exe&lt;/strong&gt;, which out of some reason is not put into the release.zip file. I copy it into the BusTest.Service \bin\Debug directory to play with and fire up a powershell. My gut feeling is, that the exe together with my dll form something that later can be registered as a Windows service. Even better the exe seems to be able to register itself - as one of the CLI Arguments (/Action:{Install|Uninstall|Server|Debug|Deploy}) suggests. If you run it without arguments it tells you what it needs.&lt;/p&gt;&lt;pre class="csharpcode"&gt;/Action:{Install|Uninstall|Server|Debug|Deploy}  Choose an action (short form /action)
/Assembly:&amp;lt;string&amp;gt;                               Assembly to execute (short form /asm)
/ConfigFile:&amp;lt;string&amp;gt;                             Configuration file (short form /config)
/Name:&amp;lt;string&amp;gt;                                   Service name (short form /name)
/Account:&amp;lt;string&amp;gt;                                (short form /A)
/Host:&amp;lt;string&amp;gt;                                   (short form /H)
/BootStrapper:&amp;lt;string&amp;gt;                           (short form /B)
@&amp;lt;file&amp;gt;                                          Read response file &lt;span class="kwrd"&gt;for&lt;/span&gt; more  options&lt;/pre&gt;
&lt;p&gt;Another one of the args, &lt;strong&gt;Host&lt;/strong&gt;, seems to want a Type, Assembly name tuple. Further digging in code it seems to want an implementation of IApplicationHost –&amp;gt; DefaultHost and LoadbalancerHost are it’s only implementations – so one of those.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;ConfigFile&lt;/strong&gt; seems to be optional and happy with the default App.confg, so I’ll use that. No, mistake, it seems to need a valid param here, too.&lt;/p&gt;
&lt;p&gt;I assume that “&lt;strong&gt;Assembly&lt;/strong&gt;” refers to my BusTest.Services assembly. But I keep getting exceptions that “BusTest” was not found. So when you wade through the code, you will find that the actual filename is expected (with extension).&lt;/p&gt;
&lt;p&gt;/&lt;strong&gt;Bootstrapper&lt;/strong&gt; refers to some implementation of Rhino’s AbstractBootstrapper. Have a look at it – it has a very nice pattern of handling configuration and IOC for plugin like projects. I created an empty implementation of that in the services project.&lt;/p&gt;
&lt;p&gt;With&lt;/p&gt;&lt;pre class="csharpcode"&gt;.\Rhino.ServiceBus.Host.exe `
/Action:&lt;span class="str"&gt;"Debug"&lt;/span&gt; `
/Name:&lt;span class="str"&gt;"BusTestSrv"&lt;/span&gt; `
/BootStrapper:&lt;span class="str"&gt;"BusTest.Services.TestBootStrapper, BusTest.Services"&lt;/span&gt; `
/ConfigFile:&lt;span class="str"&gt;"BusTest.Services.dll.config"&lt;/span&gt; `
/Host:&lt;span class="str"&gt;"Rhino.ServiceBus.Hosting.DefaultHost, Rhino.ServiceBus"&lt;/span&gt; `
/Assembly:&lt;span class="str"&gt;"BusTest.Services.dll"&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;I seem to have got across this, too. Now I need to find out how the configuration file is supposed to look like. The abstract bootstrapper in conjunction with DefaultHost (and I assume RemoteAppDomainHost, too) already set up the facility with the id “rhino.esb”. So I just need to provide a config similar to the Starbuck example and the BusTest.Client.&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;="1.0"&lt;/span&gt; &lt;span class="attr"&gt;encoding&lt;/span&gt;&lt;span class="kwrd"&gt;="utf-8"&lt;/span&gt; ?&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;configuration&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;configSections&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;section&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="castle"&lt;/span&gt;
           &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;configSections&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;castle&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;facilities&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;facility&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="rhino.esb"&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
              &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;bus&lt;/span&gt; &lt;span class="attr"&gt;threadCount&lt;/span&gt;&lt;span class="kwrd"&gt;="1"&lt;/span&gt;
                           &lt;span class="attr"&gt;numberOfRetries&lt;/span&gt;&lt;span class="kwrd"&gt;="5"&lt;/span&gt;
                           &lt;span class="attr"&gt;endpoint&lt;/span&gt;&lt;span class="kwrd"&gt;="msmq://localhost/BusTest"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
              &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;messages&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;add&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="BusTest.Messages"&lt;/span&gt;
                           &lt;span class="attr"&gt;endpoint&lt;/span&gt;&lt;span class="kwrd"&gt;="msmq://localhost/BusTest"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
              &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;messages&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;facility&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;facilities&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;castle&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;configuration&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I run it and get a boring “Press any key to continue...” in the shell. I do not follow this suggestion, thinking it might mean, the service is actually running.&lt;/p&gt;
&lt;p&gt;And when I refresh the queue in the management console, the message is gone. Now where is it? I refresh the BusTest node and have a new child node, errors, where I find my old friend, accompanied by another message - “Error description for: BusTest.Messages.SendMessage”:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;!&lt;/span&gt;&lt;span class="html"&gt;DOCTYPE&lt;/span&gt; &lt;span class="attr"&gt;html&lt;/span&gt; &lt;span class="attr"&gt;PUBLIC&lt;/span&gt; &lt;span class="kwrd"&gt;"-//W3C//DTD HTML 3.2//EN"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;html&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;head&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;meta&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="generator"&lt;/span&gt; &lt;span class="attr"&gt;content&lt;/span&gt;=
  &lt;span class="kwrd"&gt;"HTML Tidy for Windows (vers 14 February 2006), see www.w3.org"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;title&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;head&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;body&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;System.InvalidOperationException: 
The SMTP host was not specified ... at System.Net.Mail.SmtpClient.CheckHostAndPort().. &lt;br&gt;at System.Net.Mail.SmtpClient.Send(MailMessage message)..&lt;br&gt;at BusTest.Services.SendMessageService.Consume(SendMessage message) &lt;br&gt;in C:\data\BusTest\BusTest.Services\SendMessageService.cs:line 20.. &lt;br&gt;at Rhino.ServiceBus.Impl.DefaultReflection.InvokeConsume(Object consumer, Object msg).. &lt;br&gt;at Rhino.ServiceBus.Impl.DefaultServiceBus.Transport_ OnMessageArrived (Current MessageInformation msg).. &lt;br&gt;at Rhino.ServiceBus.Transport.TransportUtil.ProcessSingleMessage
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;body&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;html&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Success! &lt;/strong&gt;While this still indicates some small problem with my service implementation, it also means that the communication between the two guys is good. I fix the implementation and move the messages causing the error back to the “Queue messages” queue, build and restart the service. My server gets the messages and sends them. Yes! This was quicker than I had anticipated. &lt;/p&gt;
&lt;p&gt;I hope my notes on the subject help somebody and if anyone wants to contribute on making this sample better, please go ahead!&lt;/p&gt;
&lt;p&gt;I published the sources for this post @ BitBucket. Fork it here:&lt;br&gt;&lt;a href="https://bitbucket.org/janlimpens/rhino.servicebus.testapp/"&gt;https://bitbucket.org/janlimpens/rhino.servicebus.testapp/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Still have to find out what causes the weird IO problems I am having with my (other) app, but this here looks promising. And I have to find out what a load balancer is for. Maybe in a next post…&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1942748161021467080-5345361166935291907?l=illdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://illdev.blogspot.com/feeds/5345361166935291907/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1942748161021467080&amp;postID=5345361166935291907&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1942748161021467080/posts/default/5345361166935291907'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1942748161021467080/posts/default/5345361166935291907'/><link rel='alternate' type='text/html' href='http://illdev.blogspot.com/2010/04/building-message-bus-style-app.html' title='Building a message bus style app'/><author><name>Jan</name><uri>http://www.blogger.com/profile/04294418393369661860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_SKmxBuw1bL4/S8TajOpikQI/AAAAAAAAC4k/-9TfGE8HW_s/s1600-R/52dc0db2cdacc6e9769d074a37466317.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_SKmxBuw1bL4/S8N6qS_TjLI/AAAAAAAAC4c/9c7sv2awbfg/s72-c/image_thumb.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry></feed>
