Last active
March 16, 2021 14:05
-
-
Save frankhale/4ea7a98af9451a71943ecd77efc66d55 to your computer and use it in GitHub Desktop.
MassTransit ASPNET Core Azure ServiceBus config fail
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 void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddControllers(); | |
var queueTopic = "topic name here"; | |
var sendQueueConnectionString = "Send EndPoint Connection String Here"; | |
var receiveQueueConnectionString = "Receive EndPoint COnnection String Here"; | |
// My intent is to have this ASPNET Core API publish and also be a consumer | |
var azureServiceBusSend = Bus.Factory.CreateUsingAzureServiceBus(busFactoryConfig => | |
{ | |
busFactoryConfig.Message<MyMessage>(configTopology => | |
{ | |
configTopology.SetEntityName(queueTopic); | |
}); | |
busFactoryConfig.Host(sendQueueConnectionString, hostConfig => { }); | |
}); | |
var azureServiceBusReceive = Bus.Factory.CreateUsingAzureServiceBus(busFactoryConfig => | |
{ | |
busFactoryConfig.Message<MyMessage>(x => { x.SetEntityName(queueTopic); }); | |
busFactoryConfig.Host(receiveQueueConnectionString, hostConfig => { }); | |
busFactoryConfig.ReceiveEndpoint(queueTopic, config => | |
{ | |
config.Consumer<MyMessageConsumer>(); | |
}); | |
}); | |
services.AddMassTransit(config => | |
{ | |
config.AddBus(provider => azureServiceBusSend); | |
}); | |
services.AddSingleton<IPublishEndpoint>(azureServiceBusSend); | |
services.AddSingleton<ISendEndpointProvider>(azureServiceBusSend); | |
services.AddSingleton<IBus>(azureServiceBusSend); | |
} |
No, you just need to make sure you don't have a receive endpoint with the same name as the topic.
This was my mistake ^
Thanks, guys. This was my problem. It's starting to come together, now!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No, you just need to make sure you don't have a receive endpoint with the same name as the topic. Pretty common mistake. Specifying custom entity names is the most common path to these type of errors.