2626
2727/**
2828 * Encapsulates a shutdown condition for a connection to an AMQP broker.
29+ * Depending on HardError when calling
30+ * {@link com.rabbitmq.client.ShutdownSignalException#getReference()} we will
31+ * either get a reference to the Connection or Channel instance that fired
32+ * this exception.
2933 */
3034
3135public class ShutdownSignalException extends RuntimeException {
@@ -42,19 +46,25 @@ public class ShutdownSignalException extends RuntimeException {
4246 /** Possible explanation */
4347 private final Object _reason ;
4448
49+ /** Either Channel or Connection instance, depending on _hardError */
50+ private final Object _ref ;
51+
4552 /**
4653 * Construct a ShutdownSignalException from the arguments.
4754 * @param hardError the relevant hard error
4855 * @param initiatedByApplication if the shutdown was client-initiated
4956 * @param reason Object describing the origin of the exception
57+ * @param ref Reference to Connection or Channel that fired the signal
5058 */
5159 public ShutdownSignalException (boolean hardError ,
5260 boolean initiatedByApplication ,
53- Object reason )
61+ Object reason , Object ref )
5462 {
5563 this ._hardError = hardError ;
5664 this ._initiatedByApplication = initiatedByApplication ;
5765 this ._reason = reason ;
66+ // Depending on hardError what we got is either Connection or Channel reference
67+ this ._ref = ref ;
5868 }
5969
6070 /** @return true if this signals a connection error, or false if a channel error */
@@ -68,6 +78,9 @@ public ShutdownSignalException(boolean hardError,
6878
6979 /** @return the reason object, if any */
7080 public Object getReason () { return _reason ; }
81+
82+ /** @return Reference to Connection or Channel object that fired the signal **/
83+ public Object getReference () { return _ref ; }
7184
7285 public String toString () {
7386 return super .toString () + " (" +
0 commit comments