|
30 | 30 | public class AutorecoveringChannel implements Channel, Recoverable { |
31 | 31 | private RecoveryAwareChannelN delegate; |
32 | 32 | private AutorecoveringConnection connection; |
| 33 | + private List<ShutdownListener> shutdownHooks = new ArrayList<ShutdownListener>(); |
33 | 34 | private List<RecoveryListener> recoveryListeners = new ArrayList<RecoveryListener>(); |
34 | 35 | private List<ReturnListener> returnListeners = new ArrayList<ReturnListener>(); |
35 | 36 | private List<ConfirmListener> confirmListeners = new ArrayList<ConfirmListener>(); |
@@ -379,11 +380,16 @@ public Command rpc(Method method) throws IOException { |
379 | 380 | return delegate.rpc(method); |
380 | 381 | } |
381 | 382 |
|
| 383 | + /** |
| 384 | + * @see Connection#addShutdownListener(com.rabbitmq.client.ShutdownListener) |
| 385 | + */ |
382 | 386 | public void addShutdownListener(ShutdownListener listener) { |
| 387 | + this.shutdownHooks.add(listener); |
383 | 388 | delegate.addShutdownListener(listener); |
384 | 389 | } |
385 | 390 |
|
386 | 391 | public void removeShutdownListener(ShutdownListener listener) { |
| 392 | + this.shutdownHooks.remove(listener); |
387 | 393 | delegate.removeShutdownListener(listener); |
388 | 394 | } |
389 | 395 |
|
@@ -417,13 +423,20 @@ public void automaticallyRecover(AutorecoveringConnection connection, Connection |
417 | 423 | this.delegate = (RecoveryAwareChannelN) connDelegate.createChannel(this.getChannelNumber()); |
418 | 424 | this.delegate.inheritOffsetFrom(defunctChannel); |
419 | 425 |
|
| 426 | + this.recoverShutdownListeners(); |
420 | 427 | this.recoverReturnListeners(); |
421 | 428 | this.recoverConfirmListeners(); |
422 | 429 | this.recoverFlowListeners(); |
423 | 430 | this.recoverState(); |
424 | 431 | this.notifyRecoveryListeners(); |
425 | 432 | } |
426 | 433 |
|
| 434 | + private void recoverShutdownListeners() { |
| 435 | + for (ShutdownListener sh : this.shutdownHooks) { |
| 436 | + this.delegate.addShutdownListener(sh); |
| 437 | + } |
| 438 | + } |
| 439 | + |
427 | 440 | private void recoverReturnListeners() { |
428 | 441 | for(ReturnListener rl : this.returnListeners) { |
429 | 442 | this.delegate.addReturnListener(rl); |
|
0 commit comments