/// <summary> /// Use the bus to get a Send Endpoint that in turn will be used for sending Commands/Queries. /// </summary> private async void btnSendCommand_Click(object sender, EventArgs e) { try { // Need a Send Endpoint in order to know where to deliver the messages. _sagaSendPoint = await _azureBus.GetSendEndpointAsync(_sagaQueueName); // Create a command to send, depending on what is chosen in the dropdown. // Note: The created object is still declared as IUpdateFooCommand, which will have its effect on Masstransit when sending unless you convert it upon sending! IUpdateFooCommand commandToSend = ChooseCommandByDropdown(); commandToSend.Id = Guid.NewGuid(); commandToSend.Text = txtMessageText.Text; commandToSend.TimeStampSent = DateTime.Now; // Note: Best is NOT to Send Commands as an interface, but the concrete type. So the intended Consumer actually get the message. // Because if sent as an interface - Consumers would only understand and be able to consume that very interface, not any concrete class. // So if you have a Consumer<ConcreteClass> configured to listen on an EndPoint, but send as Send<Interface>, the message would not be understooud // and hence moved to the _skipped queue. switch (drpCommandType.SelectedIndex) { case 0: _sagaSendPoint = await _azureBus.GetSendEndpointAsync(_sagaQueueName); await _sagaSendPoint.Send((UpdateFooCommand)commandToSend); LogLine($"Message ({nameof(UpdateFooCommand)}) sent OK."); break; case 1: await _sagaSendPoint.Send((UpdateFooVersion2Command)commandToSend); LogLine($"Message ({nameof(UpdateFooVersion2Command)}) sent OK."); break; default: throw new NotImplementedException(); } } catch (Exception ex) { LogError($"Exception! \r\n ExType: {ex.GetType().Name}\r\n ExMessage: {ex.Message}\r\n"); } }