-
Notifications
You must be signed in to change notification settings - Fork 233
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
base: main
Are you sure you want to change the base?
Conversation
@dotnet-policy-service agree
|
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); | ||
}); | ||
}); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
This needs a README.md too, following the same format as the other samples. |
Example for #94