Skip to content

Instantly share code, notes, and snippets.

@frankhale
Last active March 16, 2021 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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);
}
@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