Channel is closed and never reopened when InternalConsumer.HandleModelShutdown triggers
See original GitHub issueProblem
When a consumer is stuck for 30 minutes or longer (the default timeout after which RabbitMQ.Client automatically closes the channel1), the IBasicConsumer.HandleModelShutdown
method is triggered, which logs that the channel was closed.
The channel never recovers or gets reopened, and any future messages are never consumed.
Root Cause
InternalConsumer
(which is used by PersistentConsumer
& friends) creates its own channel here:
https://github.com/EasyNetQ/EasyNetQ/blob/f614ba6b555767ac1ae96c7405fb4bbca740e868/Source/EasyNetQ/Consumer/InternalConsumer.cs#L135
InternalConsumer
does not emit an event of any kind when the channel is shutdown. (AQMP code is PreconditionFailed)
After some digging, I found that there is a ChannelClosedEvent
that gets emitted by PersistentChannel
, but InternalConsumer
does not emit this.
InternalConsumer
creates instances of IBasicConsumer
, and these receive a callback on IBasicConsumer.HandleModelShutdown
You can also register a callback via the ModelShutdown
on IModel
, which is what PersistentChannel
does.
Suggested solution
Emit ChannelClosedEvent
on the IEventBus
from InternalConsumer
so that library users can handle this problem, and/or automatically create a new channel when this problem occurs so we can recover from this situation.
Using latest EasyNetQ 6.3.1
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (5 by maintainers)
Top GitHub Comments
The issue was resolved in v7.
@amoerie just to start a discussion about the implementation #1327