title: Spring boot unable to create multiple rabbit connection factories
body: <p>I am trying to connect to and consume from two different clusters of rabbitmq using a spring boot app via xml. It works well when a single rabbit:connection-factory bean is created in the application context. However, when the second one is added, it fails to start the application with the error <strong>"Parameter 1 of method rabbitListenerContainerFactory in org.springframework.boot.autoconfigure.amqp.RabbitAnnotationDrivenConfiguration required a single bean, but 2 were found:"</strong>. How do I go about creating different factories per cluster? Please suggest an alternative way of doing this, if it's not the right approach?</p>
  
  <p>Here is the xml snippet:</p>
  
  <pre><code>&lt;rabbit:connection-factory id="firstConnectionFactory" connection-factory="firstSpringConnectionFactory"  /&gt;
  &lt;rabbit:connection-factory id="secondConnectionFactory" connection-factory="secondSpringConnectionFactory"/&gt;
  &lt;bean id="firstSpringConnectionFactory"
  class="org.springframework.amqp.rabbit.connection.RabbitConnectionFactoryBean"&gt;
      &lt;property name="useSSL" value="${rabbitmq.ssl.enabled}" /&gt;
      &lt;property name="host" value="${rabbitmq.first.host}"/&gt;
      &lt;property name="virtualHost" value="${rabbitmq.vhost}"/&gt;
      &lt;property name="port" value="${rabbitmq.cluster.port}"/&gt;
      &lt;property name="username" value="${rabbitmq.user}"/&gt;
      &lt;property name="password" value="${rabbitmq.first.password}"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="secondSpringConnectionFactory"
  class="org.springframework.amqp.rabbit.connection.RabbitConnectionFactoryBean"&gt;
      &lt;property name="useSSL" value="${rabbitmq.ssl.enabled}" /&gt;
      &lt;property name="host" value="${rabbitmq.second.host}"/&gt;
      &lt;property name="virtualHost" value="${rabbitmq.vhost}"/&gt;
      &lt;property name="port" value="${rabbitmq.cluster.port}"/&gt;
      &lt;property name="username" value="${rabbitmq.user}"/&gt;
      &lt;property name="password" value="${rabbitmq.second.password}"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>And the listener container code:</p>
  
  <pre><code>ConnectionFactory cf = rabbitConnectionFactory;//One of the connnection factories will be injected here from app context
  SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
  container.setConnectionFactory(cf);
  container.setConcurrentConsumers(count);
  container.addQueueNames(queueName);
  container.setMessageListener(listener);
  container.start();
  </code></pre>