コード例 #1
0
  public void start() throws IOException {
    if (channel == null || !channel.isOpen()) {
      channel = config.createChannel();
      channel.addShutdownListener(this);
      channel.basicQos(getPrefetchCount());

      config.declareBrokerConfiguration(channel);

      consumer = new QueueSubscriber<BasicConsumer<C, T>>(channel, this);
      channel.basicConsume(queueName, false, consumer);
    }
  }
コード例 #2
0
 private Channel doCreateBareChannel(
     ChannelCachingConnectionProxy connection, boolean transactional) {
   Channel channel = connection.createBareChannel(transactional);
   if (this.publisherConfirms) {
     try {
       channel.confirmSelect();
     } catch (IOException e) {
       logger.error("Could not configure the channel to receive publisher confirms", e);
     }
   }
   if (this.publisherConfirms || this.publisherReturns) {
     if (!(channel instanceof PublisherCallbackChannelImpl)) {
       channel = new PublisherCallbackChannelImpl(channel);
     }
   }
   if (channel != null) {
     channel.addShutdownListener(this);
   }
   return channel;
 }