rebus-org / Rebus

:bus: Simple and lean service bus implementation for .NET
https://mookid.dk/category/rebus
Other
2.26k stars 353 forks source link

About pub/sub #1110

Closed lijun727 closed 10 months ago

lijun727 commented 10 months ago

Hey,I was about to use rebus, but I ran into a problem I have two .net6 programs , one as a producer and one as a consumer,

producer program:

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddRebus(configure => configure
    .Transport(x =>
    {
        x.UseRabbitMq(rabbitMqConnectionString, rabbitMqOptions.InputQueueName);
    })
    .Routing(r => r.TypeBased().Map<Producer.TestMessage>("scaleout.consumers"))
    .Options(o => o.SetMaxParallelism(2))
);

consumer program:

var app = builder.Build();
app.Services.UseRebus(bus => bus.Advanced.SyncBus.Subscribe<Consumer.TestMessage>());

error: System.FormatException: Could not get .NET type named 'Producer.TestMessage, Producer' at Rebus.Serialization.Json.JsonSerializer.GetTypeOrNull(TransportMessage transportMessage)

I want to send TestMessage, but they have different namespaces in the producer and consumer

what should I do?

thanks

mookid8000 commented 10 months ago

Check out the "SharedNothing" sample – it demonstrates how it's possible to hook into the message deserialization and overcome discrepancies between type names. 🙂