When configuring MassTransit there are a lot of moving parts. You can have multiple endpoints, middlewares, … that all impact your application.
To understand how your bus instance is wired together you can use the GetProbeResult method:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var busControl = Bus.Factory.CreateUsingRabbitMq(cfg => | |
{ | |
cfg.Host("rabbitmq://localhost/test"); | |
sbc.ReceiveEndpoint("input_queue", ec => | |
{ | |
ec.Consumer<UpdateCustomerAddressConsumer>(); | |
}) | |
}); | |
ProbeResult result = busControl.GetProbeResult(); | |
Console.WriteLine(result.ToJsonString()); |
Before you can use the code above, you’ll need this small extension method:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class IntrospectionExtensions | |
{ | |
public static string ToJsonString(this ProbeResult result) | |
{ | |
var encoding = new UTF8Encoding(false, true); | |
using (var stream = new MemoryStream()) | |
using (var writer = new StreamWriter(stream, encoding, 1024, true)) | |
using (var jsonWriter = new JsonTextWriter(writer)) | |
{ | |
jsonWriter.Formatting = Formatting.Indented; | |
SerializerCache.Serializer.Serialize(jsonWriter, result, typeof(ProbeResult)); | |
jsonWriter.Flush(); | |
writer.Flush(); | |
return encoding.GetString(stream.ToArray()); | |
} | |
} | |
} |
More info: https://masstransit-project.com//troubleshooting/show-config.html