private Channel getChannel()

in src/main/java/com/googlesource/gerrit/plugins/rabbitmq/session/type/AMQPSession.java [64:94]


  private Channel getChannel() {
    if (!isOpen()) {
      connect();
    } else {
      try {
        Channel ch = connection.createChannel();
        int channelId = ch.getChannelNumber();
        ch.addShutdownListener(
            cause -> {
              if (cause.isInitiatedByApplication()) {
                logger.atInfo().log(MSG("Channel #%d closed by application."), channelId);
              } else {
                logger.atWarning().log(
                    MSG("Channel #%d closed. Cause: %s"), channelId, cause.getMessage());
              }
            });
        failureCount.set(0);
        logger.atInfo().log(MSG("Channel #%d opened."), channelId);
        return ch;
      } catch (IOException | AlreadyClosedException ex) {
        logger.atSevere().withCause(ex).log(MSG("Failed to open channel."));
        failureCount.incrementAndGet();
      }
      if (failureCount.get() > properties.getSection(Monitor.class).failureCount) {
        logger.atWarning().log(
            "Creating channel failed %d times, closing connection.", failureCount.get());
        disconnect();
      }
    }
    return null;
  }