title: How can I manually handle any subscribed to message type in NServiceBus?
body: <p>I'm trying to build a layer over NServiceBus to make it simpler for other developers to use.</p>
  <p>I'm trying to do without the config file and managed to get the publisher to work:</p>
  <pre><code>public class NServiceBusPublisher
  {
      private IBus _Bus { get; set; }
  
      public void NServiceBusPublisher(string argInputQueue, string argErrorQueue)
      {
          Configure configure = NServiceBus.Configure.With().DefaultBuilder();
          var transport = configure.Configurer.ConfigureComponent&lt;MsmqTransport&gt;(ComponentCallModelEnum.Singleton);
  
          transport.ConfigureProperty(t =&gt; t.InputQueue, argInputQueue);
          transport.ConfigureProperty(t =&gt; t.ErrorQueue, argErrorQueue);
          transport.ConfigureProperty(t =&gt; t.NumberOfWorkerThreads, 1);
          transport.ConfigureProperty(t =&gt; t.MaxRetries, 5);
  
          _Bus =
              configure
              .XmlSerializer()
              .MsmqTransport()
                          .IsTransactional(true)
                          .PurgeOnStartup(false)
                      .MsmqSubscriptionStorage()  
              .UnicastBus()
                  .ImpersonateSender(false)
              .CreateBus()
              .Start();
  
      }
  
      public void Publish(NServiceBus.IMessage argMessage)
      {
          _Bus.Publish(argMessage);
      }
  }
  </code></pre>
  <p>I also want to have an NServiceBus Subscriber and make it possible for developers to subscribe to any number of message types as long as the message inherits from NServiceBus.IMessage:</p>
  <pre><code>    public class NServiceBusSubscriber      
  {
      private IBus _Bus { get; set; }
  
      public void NServiceBusSubscriber(string argInputQueue, string argOutputQueue, string argErrorQueue, string messagesAssembly)
      {
          Configure configure = NServiceBus.Configure.With().DefaultBuilder();
          
          var transport = configure.Configurer.ConfigureComponent&lt;MsmqTransport&gt;(ComponentCallModelEnum.Singleton);
          transport.ConfigureProperty(t =&gt; t.InputQueue, argInputQueue);
          transport.ConfigureProperty(t =&gt; t.ErrorQueue, argErrorQueue);
          transport.ConfigureProperty(t =&gt; t.NumberOfWorkerThreads, 1);
          transport.ConfigureProperty(t =&gt; t.MaxRetries, 5);
          
          var ucb = configure.Configurer.ConfigureComponent&lt;NServiceBus.Unicast.UnicastBus&gt;(ComponentCallModelEnum.Singleton);
          ucb.ConfigureProperty(u =&gt; u.MessageOwners, new Dictionary&lt;string,string&gt;()
          {
              {messagesAssembly, argOutputQueue}
          });
  
          _Bus =
              configure
              .XmlSerializer()
              .MsmqTransport()
                          .IsTransactional(true)
                          .PurgeOnStartup(false)
                      .MsmqSubscriptionStorage()                      
              .UnicastBus()
                  .ImpersonateSender(false)
              .DoNotAutoSubscribe()
              .CreateBus()
              .Start();
  
      }
  
      public void Subscribe&lt;T&gt;() where T : NServiceBus.IMessage
      {
          _Bus.Subscribe&lt;T&gt;();
      }
  } 
  </code></pre>
  <p>The problem is that I couldn't find any way to attach an event handler to a particular message type.</p>
  <p>Could you please help me figure this out?</p>