steps to reproduce:
- You should have rabbitMq, application with RabbitConsumer
- Start rabbit + application - should successful initialize and start reading
- shutdown rabbit (emulate network issues)
application also shutdown with error because RabbitMqBackgroundService generates unhandled exception:
[11:37:00 FTL] The HostOptions.BackgroundServiceExceptionBehavior is configured to StopHost. A BackgroundService has thrown an unhandled exception, and the IHost instance is stopping. To avoid this behavior, configure this to Ignore; however the BackgroundService will not be restarted. <s:Microsoft.Extensions.Hosting.Internal.Host>
RabbitMQ.Client.Exceptions.AlreadyClosedException: Already closed: The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=320, text='CONNECTION_FORCED - broker forced connection closure with reason 'shutdown'', classId=0, methodId=0
at RabbitMQ.Client.Impl.SessionBase.Transmit(OutgoingCommand& cmd)
at RabbitMQ.Client.Impl.ModelBase.ModelSend(MethodBase method, ContentHeaderBase header, ReadOnlyMemory`1 body)
at RabbitMQ.Client.Framing.Impl.Model._Private_BasicGet(String queue, Boolean autoAck)
at RabbitMQ.Client.Impl.ModelBase.BasicGet(String queue, Boolean autoAck)
at RabbitMQ.Client.Impl.AutorecoveringModel.BasicGet(String queue, Boolean autoAck)
at Bss.Platform.RabbitMq.Consumer.Services.MessageReader.ReadAsync(IModel channel, CancellationToken token)
at Bss.Platform.RabbitMq.Consumer.Services.ConcurrentConsumer.ConsumeAsync(IModel channel, CancellationToken token)
at Bss.Platform.RabbitMq.Consumer.BackgroundServices.RabbitMqBackgroundService.ExecuteAsync(CancellationToken stoppingToken)
at Microsoft.Extensions.Hosting.Internal.Host.TryExecuteBackgroundServiceAsync(BackgroundService backgroundService)
need to add handling that situation, application should continue to work
p.s. also there is a additional problem at the rare cases - when rabbit connection is successful but Initializers fails (in my case it happens at the configuration with rabbit cluster where is rabbit nodes sleep, initializer throws 404 erorr)
steps to reproduce:
application also shutdown with error because RabbitMqBackgroundService generates unhandled exception:
need to add handling that situation, application should continue to work
p.s. also there is a additional problem at the rare cases - when rabbit connection is successful but Initializers fails (in my case it happens at the configuration with rabbit cluster where is rabbit nodes sleep, initializer throws 404 erorr)