@@ -312,6 +312,8 @@ public virtual void OnModelShutdown(ShutdownEventArgs reason)
312
312
}
313
313
}
314
314
}
315
+ lock ( m_unconfirmedSet . SyncRoot )
316
+ Monitor . Pulse ( m_unconfirmedSet . SyncRoot ) ;
315
317
m_flowControlBlock . Set ( ) ;
316
318
}
317
319
@@ -935,6 +937,9 @@ public bool WaitForConfirms()
935
937
{
936
938
lock ( m_unconfirmedSet . SyncRoot ) {
937
939
while ( true ) {
940
+ if ( CloseReason != null )
941
+ throw new OperationInterruptedException ( CloseReason ) ;
942
+
938
943
if ( m_unconfirmedSet . Count == 0 ) {
939
944
bool aux = m_onlyAcksReceived ;
940
945
m_onlyAcksReceived = true ;
@@ -945,6 +950,17 @@ public bool WaitForConfirms()
945
950
}
946
951
}
947
952
953
+ public void WaitForConfirmsOrDie ( )
954
+ {
955
+ if ( ! WaitForConfirms ( ) ) {
956
+ Close ( new ShutdownEventArgs ( ShutdownInitiator . Application ,
957
+ CommonFraming . Constants . ReplySuccess ,
958
+ "Goodbye" , new IOException ( "nack received" ) ) ,
959
+ false ) ;
960
+ throw new OperationInterruptedException ( CloseReason ) ;
961
+ }
962
+ }
963
+
948
964
public abstract void _Private_ConfirmSelect ( bool nowait ) ;
949
965
950
966
public string BasicConsume ( string queue ,
@@ -1229,7 +1245,7 @@ public void Close()
1229
1245
Close ( CommonFraming . Constants . ReplySuccess , "Goodbye" ) ;
1230
1246
}
1231
1247
1232
- public void Close ( ushort replyCode , string replyText )
1248
+ public void Close ( ushort replyCode , string replyText )
1233
1249
{
1234
1250
Close ( replyCode , replyText , false ) ;
1235
1251
}
@@ -1245,16 +1261,21 @@ public void Abort(ushort replyCode, string replyText)
1245
1261
}
1246
1262
1247
1263
public void Close ( ushort replyCode , string replyText , bool abort )
1264
+ {
1265
+ Close ( new ShutdownEventArgs ( ShutdownInitiator . Application ,
1266
+ replyCode , replyText ) ,
1267
+ abort ) ;
1268
+ }
1269
+
1270
+ public void Close ( ShutdownEventArgs reason , bool abort )
1248
1271
{
1249
1272
ShutdownContinuation k = new ShutdownContinuation ( ) ;
1250
1273
ModelShutdown += new ModelShutdownEventHandler ( k . OnShutdown ) ;
1251
1274
1252
1275
try {
1253
- if ( SetCloseReason ( new ShutdownEventArgs ( ShutdownInitiator . Application ,
1254
- replyCode ,
1255
- replyText ) ) )
1276
+ if ( SetCloseReason ( reason ) )
1256
1277
{
1257
- _Private_ChannelClose ( replyCode , replyText , 0 , 0 ) ;
1278
+ _Private_ChannelClose ( reason . ReplyCode , reason . ReplyText , 0 , 0 ) ;
1258
1279
}
1259
1280
k . Wait ( ) ;
1260
1281
} catch ( AlreadyClosedException ace ) {
0 commit comments