File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed
src/Transports/RabbitMQ/Wolverine.RabbitMQ/Internal Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,36 @@ protected async Task startNewChannel()
6868
6969 Channel . CallbackExceptionAsync += ( sender , args ) =>
7070 {
71- Logger . LogError ( args . Exception , "Callback error in Rabbit Mq agent" ) ;
71+ Logger . LogError ( args . Exception , "Callback error in Rabbit Mq agent. Attempting to restart the channel" ) ;
72+
73+ // Try to restart the connection
74+ #pragma warning disable VSTHRD110
75+ Task . Run ( async ( ) =>
76+ #pragma warning restore VSTHRD110
77+ {
78+ await Locker . WaitAsync ( ) ;
79+ try
80+ {
81+ _monitor . Remove ( this ) ;
82+ try
83+ {
84+ await teardownChannel ( ) ;
85+ }
86+ catch ( Exception e )
87+ {
88+ Logger . LogError ( e , "Error when trying to tear down a blocked channel" ) ;
89+ }
90+
91+ Channel = null ;
92+ await EnsureInitiated ( ) ;
93+ Logger . LogInformation ( "Restarted the Rabbit MQ channel" ) ;
94+ }
95+ finally
96+ {
97+ Locker . Release ( ) ;
98+ }
99+ } ) ;
100+
72101 return Task . CompletedTask ;
73102 } ;
74103
You can’t perform that action at this time.
0 commit comments