rebus-org / Rebus.RabbitMq

:bus: RabbitMQ transport for Rebus
https://mookid.dk/category/rebus
Other
62 stars 44 forks source link

Channel stays closed after connection has died #88

Closed zlepper closed 2 years ago

zlepper commented 2 years ago

I'm not 100% sure how to reliably reproduce this, without putting a computer to sleep for half a day.

But basically, if I have a program running that is using Rebus.RabbitMQ, and then put me computer to sleep, and come back the next day, all the RabbitMQ channels are in a "closed" state and refuse to be used. The first set of exceptions looks like this:

 17/11/2021 07.54.41 Warning: An error occurred when attempting to receive the next message: Rebus.Exceptions.RebusApplicationException: Unexpected exception thrown while trying to dequeue a message from rabbitmq, queue address: ConfigurationManagementService
 ---> System.Threading.Channels.ChannelClosedException: The channel has been closed.
   at System.Threading.Channels.AsyncOperation`1.GetResult(Int16 token)
   at System.Threading.Channels.AsyncOperation`1.GetResult(Int16 token)
   at System.Threading.Channels.AsyncOperation`1.GetResult(Int16 token)
   at Rebus.RabbitMq.RabbitMqTransport.Receive(ITransactionContext context, CancellationToken cancellationToken)
   at Rebus.RabbitMq.RabbitMqTransport.Receive(ITransactionContext context, CancellationToken cancellationToken)
   at Rebus.RabbitMq.RabbitMqTransport.Receive(ITransactionContext context, CancellationToken cancellationToken)
   at Rebus.RabbitMq.RabbitMqTransport.Receive(ITransactionContext context, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at Rebus.RabbitMq.RabbitMqTransport.Receive(ITransactionContext context, CancellationToken cancellationToken)
   at Rebus.Workers.ThreadPoolBased.ThreadPoolWorker.ReceiveTransportMessage(CancellationToken token, ITransactionContext context)

Afterward each time Rebus tries to get new messages, it fails with a smaller version of that message:

17/11/2021 07.55.13 Warning: An error occurred when attempting to receive the next message: Rebus.Exceptions.RebusApplicationException: Unexpected exception thrown while trying to dequeue a message from rabbitmq, queue address: ConfigurationManagementService
 ---> System.Threading.Channels.ChannelClosedException: The channel has been closed.
   at Rebus.RabbitMq.RabbitMqTransport.Receive(ITransactionContext context, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at Rebus.RabbitMq.RabbitMqTransport.Receive(ITransactionContext context, CancellationToken cancellationToken)
   at Rebus.Workers.ThreadPoolBased.ThreadPoolWorker.ReceiveTransportMessage(CancellationToken token, ITransactionContext context)