title: How to send various command type by MassTransit and RabbitMQ?
body: <p>I’m a beginner in using message brokers.<br/>
  We have a ticketing service which has multiple sub service. A supervisor service gets requests with help of a web API and sends them to sub services.<br/>
  Any request has a header which is used to detect command type (such as Reserve, Refund, Availability or etc.). We use json for serializing objects.<br/>
  Now, How to send various message types(different objects) by MassTransit from a publisher such as our supervisor system, in a way that consumer can use it easily?<br/>
  In general, is it possible to send various message type in MassTransit and rabbitMQ?<br/>
  Every consumer has only one queue for processing received messages.</p>
  <p>Thanks</p>
  <blockquote>
  <h1>Update</h1>
  </blockquote>
  <p><code>https://dotnetcodr.com/2016/08/02/messaging-with-rabbitmq-and-net-review-part-1-foundations-and-terminology/</code> <br/></p>
  <p>I read This posts suit to start in messaging with MassTransit and didn't see any example to using various message types on these and another resources:</p>
  <p>I have multiple commands and need various message types to send with them, but in examples only use a message type such as below:</p>
  <p><strong>Sender</strong></p>
  <pre><code>    private static void RunMassTransitPublisherWithRabbit()
      {
          string rabbitMqAddress = &quot;rabbitmq://localhost:5672/Ticket&quot;;
          string rabbitMqQueue = &quot;mycompany.domains.queues&quot;;
          Uri rabbitMqRootUri = new Uri(rabbitMqAddress);
  
          IBusControl rabbitBusControl = Bus.Factory.CreateUsingRabbitMq(rabbit =&gt;
          {
              rabbit.Host(rabbitMqRootUri, settings =&gt;
              {
                  settings.Password(&quot;Kalcho^Milano&quot;);
                  settings.Username(&quot;ticketadmin&quot;);
              });
          });
  
          Task&lt;ISendEndpoint&gt; sendEndpointTask = rabbitBusControl.GetSendEndpoint(new Uri(string.Concat(rabbitMqAddress, &quot;/&quot;, rabbitMqQueue)));
          ISendEndpoint sendEndpoint = sendEndpointTask.Result;
  
          Task sendTask = sendEndpoint.Send&lt;IRegisterCustomer&gt;(new
          {
              Address = &quot;New Street&quot;,
              Id = Guid.NewGuid(),
              Preferred = true,
              RegisteredUtc = DateTime.UtcNow,
              Name = &quot;Nice people LTD&quot;,
              Type = 1,
              DefaultDiscount = 0
          });
          Console.ReadKey();
      }
  </code></pre>
  <p><strong>Receiver</strong></p>
  <pre><code>        private static void RunMassTransitReceiverWithRabbit()
      {
          IBusControl rabbitBusControl = Bus.Factory.CreateUsingRabbitMq(rabbit =&gt;
          {
              IRabbitMqHost rabbitMqHost = rabbit.Host(new Uri(&quot;rabbitmq://localhost:5672/Ticket&quot;), settings =&gt;
              {
                  settings.Password(&quot;Kalcho^Milano&quot;);
                  settings.Username(&quot;ticketadmin&quot;);
              });
  
              rabbit.ReceiveEndpoint(rabbitMqHost, &quot;mycompany.domains.queues&quot;, conf =&gt;
              {
                  conf.Consumer&lt;RegisterCustomerConsumer&gt;();
              });
          });
  
          rabbitBusControl.Start();
          Console.ReadKey();
  
          rabbitBusControl.Stop();
      }
  </code></pre>
  <p><code>IRegisterCustomer</code> is an interface and I can only get message content in  <code>rabbit.ReceiveEndpoint</code> and convert to usable object.</p>
  <p>Now, How to use various message types such as <code>IReserveTicket</code>, <code>IRefundTicket</code> and <code>IGetAvailability</code> to sending and receiving messages?</p>
  <p>Thanks again</p>