I have an issue with MassTransit not sending messages with the following code - this is a port from our Azure Service Bus code which works fine. The examples in GitHub populate the Queue - Starbucks example, so my infrastructure is working.
Can anyone please suggest why this is not sending messages? I have created both the queue and exchange, and tried without.
The console app prints out the expected results.
Thanks in advance.
public class Program
{
static void Main()
{
IBusControl busControl = CreateBus();
TaskUtil.Await(() => busControl.StartAsync());
List<Task> tList = new List<Task>();
for (int i = 0; i < 10; i++)
{
var t = Send(busControl);
tList.Add(t);
}
Task.WaitAll(tList.ToArray());
Console.WriteLine("done!");
}
private static async Task Send(IBusControl busControl)
{
var endpoint = await busControl.GetSendEndpoint(new Uri("rabbitmq://localhost/test"));
Console.WriteLine("Sending");
await endpoint.Send(new SomethingHappenedMessage()
{
What = "Stuff",
When = DateTime.Now
});
Console.WriteLine("Sent");
}
static IBusControl CreateBus()
{
return Bus.Factory.CreateUsingRabbitMq(x => x.Host(new Uri("rabbitmq://localhost"), h =>
{
h.Username("guest");
h.Password("guest");
}));
}
}
public interface SomethingHappened
{
string What { get; }
DateTime When { get; }
}
public class SomethingHappenedMessage : SomethingHappened
{
public string What { get; set; }
public DateTime When { get; set; }
}
testexchange bound to thetestqueue? - Chris PattersonSend, notPublish- and it should be your last choice, to be honest. Start your receiveEndpoints before your producers come online. It isn't that complicated. Don't try to make it hard. - Chris Patterson