Describe the bug
Hi,
I am in dire need of a working example of how to get the Weather Forecast template running with MassTransit.
I got it to work without MassTransit already, so the Messages are working fine.
I hit dead ends all the time. I think I have found a way for the Consumer side but the website gives me a headache.
I use the Packages
<PackageReference Include="CommunityToolkit.Aspire.MassTransit.RabbitMQ" Version="9.4.0" />
<PackageReference Include="MassTransit.MessagePack" Version="8.4.0" />
<PackageReference Include="MessagePack" Version="3.1.3" />
I have defined 2 Messages WeatherRequestMessage and WeatherResponseMessage.
My Problem on the Webapplication
I want to use a specific Exchange and RoutingKey when I send the RequestMessage
This code should be enough if the rest is configured correctly
namespace My.Web;
using MassTransit;
using Messages.Weather;
public sealed class WeatherApiClient(ILogger<WeatherApiClient> logger, IRequestClient<WeatherRequestMessage> requestClient)
{
public async Task<WeatherResponse[]> GetWeatherAsync(int maxItems = 10, CancellationToken cancellationToken = default)
{
Response<WeatherResponseMessage> response = await requestClient.GetResponse<WeatherResponseMessage>(new WeatherRequestMessage(), cancellationToken).ConfigureAwait(false);
logger.LogInformation("Published message to requestClient");
return response.Message.WeatherForecastArray;
}
}
}
in Program.cs i tried something like this but that gives me errors
builder.AddMassTransitRabbitMq("MessageBus",
static settings => { settings.DisableTelemetry = false; },
static config =>
{
config.UsingRabbitMq(static (context, cfg) =>
{
var configuration = context.GetRequiredService<IConfiguration>();
string? host = configuration["RabbitMQ:Host"];
cfg.Host(host);
cfg.UseMessagePackSerializer();
cfg.AddPublishMessageTypes([typeof(WeatherRequestMessage)],
(configurator, type) =>
{
configurator
.BindQueue(configuration["RabbitMQ:RequestExchange"]!,
configuration["RabbitMQ:RequestRoutingKey"]);
});
});
});
Regression
No response
Steps to reproduce
All examples found that uses Aspire+MassTransit do not even mention the builder.AddMassTransitRabbitMq extension.
Expected behavior
A working example for this common use case.
Screenshots
No response
IDE and version
VS 2022
IDE version
No response
Nuget packages
<PackageReference Include="CommunityToolkit.Aspire.MassTransit.RabbitMQ" Version="9.4.0" />
<PackageReference Include="MassTransit.MessagePack" Version="8.4.0" />
<PackageReference Include="MessagePack" Version="3.1.3" />
Additional context
No response
Help us help you
No, just wanted to report this
Describe the bug
Hi,
I am in dire need of a working example of how to get the Weather Forecast template running with MassTransit.
I got it to work without MassTransit already, so the Messages are working fine.
I hit dead ends all the time. I think I have found a way for the Consumer side but the website gives me a headache.
I use the Packages
I have defined 2 Messages WeatherRequestMessage and WeatherResponseMessage.
My Problem on the Webapplication
I want to use a specific Exchange and RoutingKey when I send the RequestMessage
This code should be enough if the rest is configured correctly
in Program.cs i tried something like this but that gives me errors
Regression
No response
Steps to reproduce
Expected behavior
A working example for this common use case.
Screenshots
No response
IDE and version
VS 2022
IDE version
No response
Nuget packages
Additional context
No response
Help us help you
No, just wanted to report this