Skip to content

Conversation

@baotoq
Copy link

@baotoq baotoq commented Apr 15, 2024

Example for #94

@baotoq
Copy link
Author

baotoq commented Apr 15, 2024 via email

Comment on lines 13 to 22
var connectionString = builder.Configuration.GetConnectionString("messaging");

builder.Services.AddMassTransit(s =>
{
s.AddConsumers(Assembly.GetExecutingAssembly());
s.UsingRabbitMq((context, cfg) =>
{
cfg.Host(new Uri(connectionString!), "/");
cfg.ConfigureEndpoints(context);
});
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this use the Aspire RabbitMQ component rather than manually grabbing the connection string?

Copy link
Author

@baotoq baotoq Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we do that?, I try and can't figure how can we do it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eerhardt thoughts? I'm looking at https://masstransit.io/documentation/configuration/transports/rabbitmq and not seeing any clear way to control the creation of the RabbitMQ client instance MassTransit uses.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure people would use the Aspire component. Apps that use MassTransit don't code directly to the RabbitMQ IConnection, but instead to MassTransit APIs, right? They don't want the IConnection or even the ConnectionFactory in DI.

Looking through MassTransit.RabbitMqTransport, it has its own system for configuring the underlying connection (and a lot more code than I was expecting). I'm not seeing a clear way either. MassTransit doesn't look in DI at all for the ConnectionFactory or IConnection, it assumes it has to new them up itself.

The drawbacks of not using the Aspire component is that you will need to enable the Health Check yourself, and when Tracing is supported, it will need to be enabled (since the component will do that automatically).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Masstransit doesn't support this, but we should attempt to help libraries integrate with the underlying client libs as much as possible so that aspire components just work.

@DamianEdwards
Copy link
Member

This needs a README.md too, following the same format as the other samples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants