|
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>(); |
@@ -430,11 +431,16 @@ public Command rpc(Method method) throws IOException { |
430 | 431 | return delegate.rpc(method); |
431 | 432 | } |
432 | 433 |
|
| 434 | + /** |
| 435 | + * @see Connection#addShutdownListener(com.rabbitmq.client.ShutdownListener) |
| 436 | + */ |
433 | 437 | public void addShutdownListener(ShutdownListener listener) { |
| 438 | + this.shutdownHooks.add(listener); |
434 | 439 | delegate.addShutdownListener(listener); |
435 | 440 | } |
436 | 441 |
|
437 | 442 | public void removeShutdownListener(ShutdownListener listener) { |
| 443 | + this.shutdownHooks.remove(listener); |
438 | 444 | delegate.removeShutdownListener(listener); |
439 | 445 | } |
440 | 446 |
|
@@ -468,13 +474,20 @@ public void automaticallyRecover(AutorecoveringConnection connection, Connection |
468 | 474 | this.delegate = (RecoveryAwareChannelN) connDelegate.createChannel(this.getChannelNumber()); |
469 | 475 | this.delegate.inheritOffsetFrom(defunctChannel); |
470 | 476 |
|
| 477 | + this.recoverShutdownListeners(); |
471 | 478 | this.recoverReturnListeners(); |
472 | 479 | this.recoverConfirmListeners(); |
473 | 480 | this.recoverFlowListeners(); |
474 | 481 | this.recoverState(); |
475 | 482 | this.notifyRecoveryListeners(); |
476 | 483 | } |
477 | 484 |
|
| 485 | + private void recoverShutdownListeners() { |
| 486 | + for (ShutdownListener sh : this.shutdownHooks) { |
| 487 | + this.delegate.addShutdownListener(sh); |
| 488 | + } |
| 489 | + } |
| 490 | + |
478 | 491 | private void recoverReturnListeners() { |
479 | 492 | for(ReturnListener rl : this.returnListeners) { |
480 | 493 | this.delegate.addReturnListener(rl); |
|
0 commit comments