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 container for RabbitMq not ready, crashing other Aspire managed apps using Wolverine/RabbitMq #752

Closed
yarseyah opened this issue Feb 23, 2024 · 1 comment

Comments

@yarseyah
Copy link

Describe the bug
I've been trying to use Aspire (Preview 3) to implement my architecture, using RabbitMq via Wolverine to get things communicating appropriately, I'm aware of the open #635 that seems to be working out how to use the Aspire client services, however in my case I'm purely using host to provide the necessary RabbitMq. Within the Aspire launched applications (web-server, API, consumers etc) I want to use pure RabbitMq via Wolverine, e.g. not the IConnection etc that the Aspire client libraries add. However, I'm having startup issues with the client crashing immediately.

To Reproduce
Steps to reproduce the behaviour:

  1. Add to the Aspire host:
var messageQueue = builder.AddRabbitMQ("command-queue");
  1. Add to an Aspire invoked application
builder.Host.UseWolverine(options => {
  var connectionString = builder.Configuration.GetConnectionString("command-queue")
                           ?? throw new InvalidOperationException();
  options.UseRabbitMq(new Uri(connectionString))
         .UseSenderConnectionOnly();    
});
  1. Starting of client crashes with the following exception:
024-02-23T17:58:52.4817620 fail: Wolverine.Runtime.WolverineRuntime[0]
      Failed to start the Wolverine messaging
      RabbitMQ.Client.Exceptions.BrokerUnreachableException: None of the specified endpoints were reachable
       ---> System.IO.IOException: connection.start was never received, likely due to a network timeout
         at RabbitMQ.Client.Framing.Impl.Connection.StartAndTune()
         at RabbitMQ.Client.Framing.Impl.Connection.Open(Boolean insist)
         at RabbitMQ.Client.Framing.Impl.Connection..ctor(IConnectionFactory factory, Boolean insist, IFrameHandler frameHandler, String clientProvidedName)
         at RabbitMQ.Client.Framing.Impl.Connection..ctor(IConnectionFactory factory, Boolean insist, IFrameHandler frameHandler, ArrayPool`1 memoryPool, String clientProvidedName)
         at RabbitMQ.Client.Framing.Impl.AutorecoveringConnection.Init(IFrameHandler fh)
         at RabbitMQ.Client.Framing.Impl.AutorecoveringConnection.Init(IEndpointResolver endp
oints)
         at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName)
         --- End of inner exception stack trace ---
         at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName)
         at RabbitMQ.Client.ConnectionFactory.CreateConnection(String clientProvidedName)
         at RabbitMQ.Client.ConnectionFactory.CreateConnection()
         at Wolverine.RabbitMQ.Internal.RabbitMqTransport.BuildConnection()
         at Wolverine.RabbitMQ.Internal.RabbitMqTransport.ConnectAsync(IWolverineRuntime runtime)
         at Wolverine.Transports.BrokerTransport`1.InitializeAsync(IWolverineRuntime runtime)
         at Wolverine.Runtime.WolverineRuntime.startMessagingTransportsAsync()
         at Wolverine.Runtime.WolverineRuntime.StartAsync(CancellationToken cancellationToken)

This can be overcome by something hacky such as the following at the end of the program.cs for a minimal API :

// Map routes

Console.WriteLine("Waiting for 5 seconds before starting the application");
await Task.Delay(5000);
Console.WriteLine("Starting the application after 5 seconds to allow RabbitMQ to start");

app.Run();
}

Expected behaviour
Initialisation code waits for the RabbitMq container to start. (configurable timeout or resilience pattern?).

@jeremydmiller
Copy link
Member

Wolverine doesn't yet support Aspire, here's where we're tracking that work: #635

And no, I don't have a perfect idea of when that will be done, but it's on the radar.

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

No branches or pull requests

2 participants