/**
  * Re-initializes this container's Rabbit message consumers, if not initialized already. Then
  * submits each consumer to this container's task executor.
  *
  * @throws Exception
  */
 protected void doStart() throws Exception {
   super.doStart();
   synchronized (this.consumersMonitor) {
     initializeConsumers();
     if (this.consumers == null) {
       logger.info(
           "Consumers were initialized and then cleared (presumably the container was stopped concurrently)");
       return;
     }
     Set<AsyncMessageProcessingConsumer> processors =
         new HashSet<AsyncMessageProcessingConsumer>();
     for (BlockingQueueConsumer consumer : this.consumers) {
       AsyncMessageProcessingConsumer processor = new AsyncMessageProcessingConsumer(consumer);
       processors.add(processor);
       this.taskExecutor.execute(processor);
     }
     for (AsyncMessageProcessingConsumer processor : processors) {
       FatalListenerStartupException startupException = processor.getStartupException();
       if (startupException != null) {
         throw new AmqpIllegalStateException(
             "Fatal exception on listener startup", startupException);
       }
     }
   }
 }
 protected void addAndStartConsumers(int delta) {
   synchronized (this.consumersMonitor) {
     if (this.consumers != null) {
       for (int i = 0; i < delta; i++) {
         BlockingQueueConsumer consumer = createBlockingQueueConsumer();
         this.consumers.put(consumer, true);
         AsyncMessageProcessingConsumer processor = new AsyncMessageProcessingConsumer(consumer);
         this.taskExecutor.execute(processor);
         try {
           FatalListenerStartupException startupException = processor.getStartupException();
           if (startupException != null) {
             this.consumers.remove(consumer);
             throw new AmqpIllegalStateException(
                 "Fatal exception on listener startup", startupException);
           }
         } catch (InterruptedException ie) {
           Thread.currentThread().interrupt();
         } catch (Exception e) {
           consumer.stop();
           logger.error("Error starting new consumer", e);
           consumers.remove(consumer);
         }
       }
     }
   }
 }