We're migrating our web application to azure cloud and switching from RabbitMQ to Azure Service Bus.
We don't have any issue using RabbitMQ in azure. However, we're having problem to send message to azure service bus. All messages went to _skipped queue and I see following errors
Our web application is .net core based. The MassTransit packages we installed
1. Masstransit.Azure.ServiceBus.Core v5.1.5
2. Masstransit.Extensions.Dependencyinjection v5.1.5
For testing purpose, i've downloaded sample code from following URL and updated the code to use azure service bus instead of RabbitMQ
using GreenPipes;
using MassTransit;
using MassTransit.Azure.ServiceBus.Core;
using MassTransit.ExtensionsDependencyInjectionIntegration;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
namespace WebApplication1
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddScoped<IService, Service>();
services.AddScoped<DoSomethingConsumer>();
services.AddMassTransit(x =>
{
// add the consumer, for LoadFrom
x.AddConsumer<DoSomethingConsumer>();
});
//services.AddSingleton(provider => Bus.Factory.CreateUsingRabbitMq(cfg =>
//{
// var host = cfg.Host("localhost", "/", h => { });
// cfg.ReceiveEndpoint(host, "web-service-endpoint", e =>
// {
// e.PrefetchCount = 16;
// e.UseMessageRetry(x => x.Interval(2, 100));
// e.LoadFrom(provider);
// EndpointConvention.Map<DoSomething>(e.InputAddress);
// });
//}));
services.AddSingleton(provider => Bus.Factory.CreateUsingAzureServiceBus(cfg =>
{
{
configurator.OperationTimeout = TimeSpan.FromSeconds(5);
});
//cfg.UseExtensionsLogging(loggerFactory);
cfg.ReceiveEndpoint(host, "testqueue", e =>
{
e.PrefetchCount = 1;
e.UseMessageRetry(x => x.Interval(2, 100));
e.LoadFrom(provider);
EndpointConvention.Map<DoSomething>(e.InputAddress);
});
}));
services.AddSingleton<IPublishEndpoint>(provider => provider.GetRequiredService<IBusControl>());
services.AddSingleton<ISendEndpointProvider>(provider => provider.GetRequiredService<IBusControl>());
services.AddSingleton<IBus>(provider => provider.GetRequiredService<IBusControl>());
services.AddScoped(provider => provider.GetRequiredService<IBus>().CreateRequestClient<DoSomething>());
services.AddSingleton<IHostedService, BusService>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseMvc();
}
}
}
However, the message doesn't seem to have been sent to intended queue - 'testqueue'. I suspect the error has something to do with SAS authorisation and SAS token was not properly set.