Starts in:
2 DAYS
18 HRS
11 MIN
52 SEC
Starts in:
2 D
18 H
11 M
52 S
Open Closed

Rebus, RabbitMQ not available on server restart #3684


User avatar
0
dmeagor created
  • ABP Framework version: v5.3.0
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes

When we do a restart of our production server, sometimes RabbitMq has not yet started, causing the application to never start. I'm not sure if this is something which should be handled in the abp code?

Volo.Abp.AbpInitializationException: An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module Volo.Abp.EventBus.Rebus.AbpEventBusRebusModule, Volo.Abp.EventBus.Rebus, Version=5.3.0.0, Culture=neutral, PublicKeyToken=null: An exception was thrown while activating λ:Rebus.Internals.ServiceCollectionBusDisposalFacility -> λ:Rebus.Bus.IBus -> λ:Rebus.Config.IBusStarter.. See the inner exception for details.
 ---> Autofac.Core.DependencyResolutionException: An exception was thrown while activating λ:Rebus.Internals.ServiceCollectionBusDisposalFacility -> λ:Rebus.Bus.IBus -> λ:Rebus.Config.IBusStarter.
 ---> Rebus.Injection.ResolutionException: Could not resolve Rebus.Bus.IBus with decorator depth 0 - registrations: Rebus.Injection.Injectionist+Handler
 ---> RabbitMQ.Client.Exceptions.BrokerUnreachableException: None of the specified endpoints were reachable
 ---> System.AggregateException: One or more errors occurred. (Connection failed)
 ---> RabbitMQ.Client.Exceptions.ConnectFailureException: Connection failed
 ---> System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it.

4 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Actually, this is not related to ABP

    You can see the dicussion on Rebus: https://github.com/rebus-org/Rebus/issues/492

  • User Avatar
    0
    dmeagor created

    If you follow your own link then you will see that the issue was moved to the following issue and then marked as Completed

    https://github.com/rebus-org/Rebus.RabbitMq/issues/3

    Currently our application fails every time the server is rebooted and there doesn't appear to be any obvious way to correct this from our side.

    Is there no way to put a short say 5 second delay and retry loop into the rebus setup code?

  • User Avatar
    0
    dmeagor created

    I've been in contact with the author of Rebus and they've confirmed to me that the behaviour is intended.

    Connection errors bubble up to the calling app (in this case ABP) and any retry logic needs to be handled there.

    https://github.com/rebus-org/Rebus.RabbitMq/issues/98#

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I agree with what mookid8000 said, If rebus can't connect to RabbitMQ, it's better to throw an exception to let the application stop, in this way you can quickly find the problem and fix it.

    But However, you can do it:

    Open your module class:

    public override void OnPreApplicationInitialization(ApplicationInitializationContext context)
    {
        Policy.Handle<Exception>().WaitAndRetry(5, retryCount => TimeSpan.FromSeconds(retryCount))
            .Execute(() =>
            {
                context.ServiceProvider.UseRebus();
            });
        
    }
    

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06