0

I was trying to configure a microservice that would be able to listen a 'NewTenant' event On creation of the tenant a new vhost in rabbitmq is activated and the event is published on the main servicebus.

But when trying to add a new bus instance for this vhost I found out there is a interface needed for the registration. Anybody have any ideas on how MSDI and masstransit can be configured for this purpose?

I want to listen to new events on the new tenant bus for all consumers, but have it scoped for the tenant or have a way to check the queue for tentant information. But I also want to be able to publish on the correct bus, so maybe instead of injecting the IBus, injecting a ITenantbus or something like that?

All ideas are welcome

foreach (var tenant in TenantService.GetTenants())
                {
                    services.AddMassTransit<ITenantBus, TenantBus>(x =>
                    {
                        x.AddConsumer<MyConsumer>();

                        x.SetKebabCaseEndpointNameFormatter();

                        x.UsingRabbitMq((context, cfg) =>
                        {
                            cfg.Host("rabbitmq://my-tenant-vhost", o =>
                            {
                                o.Username("tenantusername");
                                o.Password("tenantpassword");
                            });
                            cfg.ConfigureEndpoints(context);
                        });
                    });
                }

A way to configure this but being able to set the tenant id on the tenant bus instance would be great.

0 Answers0