Probably.
Tested with version 5.5.4 and 5.5.5-develop
I have created two simple asp.net core applications. One acts as a consumer and the other one acts as producer.
Consumer application should receive message.
Message successfully hits RabbitMQ but is then moved to the skip queue. In consumer application debug message is printed: MassTransit.Messages: Debug: SKIP rabbitmq://localhost/test-queue 7a000000-9a3c-0005-69d4-08d717e81ed5
Producer
using System;
using MassTransit;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace WebApplication1
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddMassTransit(x =>
{
x.AddBus(provider => Bus.Factory.CreateUsingRabbitMq(cfg =>
{
var host = cfg.Host(new Uri("rabbitmq://localhost"), hostConfigurator =>
{
hostConfigurator.Username("guest");
hostConfigurator.Password("guest");
});
}));
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ISendEndpointProvider sendEndpointProvider)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", async context =>
{
var endpoint = await sendEndpointProvider.GetSendEndpoint(new Uri("rabbitmq://localhost/test-queue"));
await endpoint.Send<CreateUser>(new {
MyName = "justmyname"
});
await context.Response.WriteAsync("Hello World!");
});
});
}
}
public interface CreateUser
{
public string MyName { get; }
}
}
Consumer
using System;
using System.Threading.Tasks;
using GreenPipes;
using MassTransit;
using MassTransit.AspNetCoreIntegration;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace WebApplication2
{
public class Startup
{
private IConfiguration Configuration { get; }
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddHealthChecks();
//services.AddScoped<CreateUserConsumer>();
// Register MassTransit
services.AddMassTransit(x =>
{
x.AddConsumer<CreateUserConsumer>();
x.AddBus(provider => Bus.Factory.CreateUsingRabbitMq(cfg =>
{
var host = cfg.Host(new Uri("rabbitmq://localhost"), hostConfigurator =>
{
hostConfigurator.Username("guest");
hostConfigurator.Password("guest");
});
cfg.ReceiveEndpoint(host, "test-queue", ep =>
{
ep.PrefetchCount = 16;
ep.UseMessageRetry(r => r.Interval(2, 100));
ep.ConfigureConsumer<CreateUserConsumer>(provider);
});
}));
});
services.AddMassTransitHostedService();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHealthChecks("/health", new HealthCheckOptions { Predicate = check => check.Tags.Contains("ready") });
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", async context =>
{
await context.Response.WriteAsync("Hello World!");
});
});
}
}
public class CreateUserConsumer : IConsumer<CreateUser>
{
public async Task Consume(ConsumeContext<CreateUser> context)
{
Console.WriteLine($"Updating customer: {context.Message.MyName}");
await Console.Out.WriteLineAsync($"Updating customer: {context.Message.MyName}");
}
}
public interface CreateUser
{
public string MyName { get; set; }
}
}
After hours of searching I've finally resolved this issue. Apparently, CreateUser in producer and consumer app must have same namespace.
Most helpful comment
After hours of searching I've finally resolved this issue. Apparently,
CreateUserin producer and consumer app must have same namespace.