Skip to content

Instantly share code, notes, and snippets.

@frankhale
Last active March 16, 2021 14:05
Show Gist options
  • Save frankhale/4ea7a98af9451a71943ecd77efc66d55 to your computer and use it in GitHub Desktop.
Save frankhale/4ea7a98af9451a71943ecd77efc66d55 to your computer and use it in GitHub Desktop.
MassTransit ASPNET Core Azure ServiceBus config fail
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);
}
@phatboyg
Copy link

phatboyg commented Mar 15, 2021

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.

@frankhale
Copy link
Author

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 ^

@garyman99
Copy link

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