Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aspire masstransit sample #193

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Aspire masstransit sample #193

wants to merge 11 commits into from

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants