Code review comment: @anuchandy How often will this chain be called? I was thinking back to where we had that high memory usage because it was eagerly assembling and creating the exception.... Do we need to consider `Mono.defer(() -> Mono.error(...))`?

Code under review:
Mono<ServiceBusReceiveLink> getActiveLink() {
        if (this.receiveLink != null) {
            return Mono.just(this.receiveLink);
        }
        return Mono.defer(() -> createSessionReceiveLink()
            .flatMap(link -> link.getEndpointStates()
                .filter(e -> e == AmqpEndpointState.ACTIVE)
                .next()
                
                
                
                .switchIfEmpty(Mono.error(() ->
                    new AmqpException(true, "Session receive link completed without being active", null)))
                .timeout(operationTimeout)
                .then(Mono.just(link))))
            .retryWhen(Retry.from(retrySignals -> retrySignals.flatMap(signal -> {
                final Throwable failure = signal.failure();
                LOGGER.atInfo()
                    .addKeyValue(ENTITY_PATH_KEY, entityPath)
                    .addKeyValue("attempt", signal.totalRetriesInARow())
                    .log("Error occurred while getting unnamed session.", failure);

                if (isDisposed.get()) {
                    return Mono.<Long>error(new AmqpException(false, "SessionManager is already disposed.", failure,
                        getErrorContext()));
                } else if (failure instanceof TimeoutException) {
                    return Mono.delay(SLEEP_DURATION_ON_ACCEPT_SESSION_EXCEPTION);
                } else if (failure instanceof AmqpException
                    && ((AmqpException) failure).getErrorCondition() == AmqpErrorCondition.TIMEOUT_ERROR) {
                    return Mono.delay(SLEEP_DURATION_ON_ACCEPT_SESSION_EXCEPTION);
                } else if (failure instanceof AmqpException
                    && ((AmqpException) failure).isTransient()) {
                    return Mono.delay(SLEEP_DURATION_ON_ACCEPT_SESSION_EXCEPTION);
                } else {
                    return Mono.<Long>error(failure);
                }
            })));
    }

Line commented on: new AmqpException(true, "Session receive link completed without being active", null)))

Revised code:
Mono<ServiceBusReceiveLink> getActiveLink() {
        if (this.receiveLink != null) {
            return Mono.just(this.receiveLink);
        }
        return Mono.defer(() -> createSessionReceiveLink()
            .flatMap(link -> link.getEndpointStates()
                .filter(e -> e == AmqpEndpointState.ACTIVE)
                .next()
                
                
                
                .switchIfEmpty(Mono.error(() ->
                    new AmqpException(true, "Session receive link completed without being active", null)))
                .timeout(operationTimeout)
                .then(Mono.just(link))))
            .retryWhen(Retry.from(retrySignals -> retrySignals.flatMap(signal -> {
                final Throwable failure = signal.failure();
                LOGGER.atInfo()
                    .addKeyValue(ENTITY_PATH_KEY, entityPath)
                    .addKeyValue("attempt", signal.totalRetriesInARow())
                    .log("Error occurred while getting unnamed session.", failure);

                if (isDisposed.get()) {
                    return Mono.<Long>error(new AmqpException(false, "SessionManager is already disposed.", failure,
                        getErrorContext()));
                } else if (failure instanceof TimeoutException) {
                    return Mono.delay(SLEEP_DURATION_ON_ACCEPT_SESSION_EXCEPTION);
                } else if (failure instanceof AmqpException
                    && ((AmqpException) failure).getErrorCondition() == AmqpErrorCondition.TIMEOUT_ERROR) {
                    return Mono.delay(SLEEP_DURATION_ON_ACCEPT_SESSION_EXCEPTION);
                } else {
                    final long id = System.nanoTime();
                    LOGGER.atInfo()
                            .addKeyValue(TRACKING_ID_KEY, id)
                            .log("Unable to acquire new session.", failure);
                    
                    
                    
                    return Mono.<Long>error(failure)
                            .publishOn(Schedulers.boundedElastic())
                            .doOnError(e -> LOGGER.atInfo()
                                    .addKeyValue(TRACKING_ID_KEY, id)
                                    .log("Emitting the error signal received for session acquire attempt.", e)
                    );
                }
            })));
    }