/**
  * 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);
       }
     }
   }
 }
 @Override
 protected void validateConfiguration() {
   super.validateConfiguration();
   if (isSubscriptionDurable() && this.concurrentConsumers != 1) {
     throw new IllegalArgumentException(
         "Only 1 concurrent consumer supported for durable subscription");
   }
 }
  /**
   * Avoid the possibility of not configuring the CachingConnectionFactory in sync with the number
   * of concurrent consumers.
   */
  @Override
  protected void validateConfiguration() {

    super.validateConfiguration();

    Assert.state(
        !(getAcknowledgeMode().isAutoAck() && transactionManager != null),
        "The acknowledgeMode is NONE (autoack in Rabbit terms) which is not consistent with having an "
            + "external transaction manager. Either use a different AcknowledgeMode or make sure the transactionManager is null.");

    if (this.getConnectionFactory() instanceof CachingConnectionFactory) {
      CachingConnectionFactory cf = (CachingConnectionFactory) getConnectionFactory();
      if (cf.getChannelCacheSize() < this.concurrentConsumers) {
        cf.setChannelCacheSize(this.concurrentConsumers);
        logger.warn(
            "CachingConnectionFactory's channelCacheSize can not be less than the number of concurrentConsumers so it was reset to match: "
                + this.concurrentConsumers);
      }
    }
  }
 protected void doStop() {
   shutdown();
   super.doStop();
 }
 /** Registers this listener container as JMS ExceptionListener on the shared connection. */
 @Override
 protected void prepareSharedConnection(Connection connection) throws JMSException {
   super.prepareSharedConnection(connection);
   connection.setExceptionListener(this);
 }
 /** Re-initializes this container's JMS message consumers, if not initialized already. */
 @Override
 protected void doStart() throws JMSException {
   super.doStart();
   initializeConsumers();
 }