/** * True if the connection is open. * @return true if the connection is open * @throws AutoRecoverConnectionNotCurrentlyOpenException if the connection is an * {@link AutorecoveringConnection} and is currently closed; this is required to * prevent the {@link CachingConnectionFactory} from discarding this connection * and opening a new one, in which case the "old" connection would eventually be recovered * and orphaned - also any consumers belonging to it might be recovered too * and the broker will deliver messages to them when there is no code actually running * to deal with those messages (when using the {@code SimpleMessageListenerContainer}). * If we have actually closed the connection * (e.g. via {@link CachingConnectionFactory#resetConnection()}) this will return false. */ @Override public boolean isOpen() { if (!this.explicitlyClosed && this.delegate instanceof AutorecoveringConnection && !this.delegate.isOpen()) { throw new AutoRecoverConnectionNotCurrentlyOpenException("Auto recovery connection is not currently open"); } return this.delegate != null && (this.delegate.isOpen()); }
assertThat(e.getMessage(), equalTo("Auto recovery connection is not currently open"));
/** * True if the connection is open. * @return true if the connection is open * @throws AutoRecoverConnectionNotCurrentlyOpenException if the connection is an * {@link AutorecoveringConnection} and is currently closed; this is required to * prevent the {@link CachingConnectionFactory} from discarding this connection * and opening a new one, in which case the "old" connection would eventually be recovered * and orphaned - also any consumers belonging to it might be recovered too * and the broker will deliver messages to them when there is no code actually running * to deal with those messages (when using the {@code SimpleMessageListenerContainer}). * If we have actually closed the connection * (e.g. via {@link CachingConnectionFactory#resetConnection()}) this will return false. */ @Override public boolean isOpen() { if (!this.explicitlyClosed && this.delegate instanceof AutorecoveringConnection && !this.delegate.isOpen()) { throw new AutoRecoverConnectionNotCurrentlyOpenException("Auto recovery connection is not currently open"); } return this.delegate != null && (this.delegate.isOpen()); }