new HashMap<Object, org.springframework.amqp.rabbit.connection.ConnectionFactory>(2);
factories.put("foo", connectionFactory1);
factories.put("bar", connectionFactory2);
AbstractRoutingConnectionFactory connectionFactory = new SimpleRoutingConnectionFactory();
connectionFactory.setTargetConnectionFactories(factories);
final RabbitTemplate template = new RabbitTemplate(connectionFactory);
Expression expression = new SpelExpressionParser()
.parseExpression("T(org.springframework.amqp.rabbit.core.RabbitTemplateTests)" +
".LOOKUP_KEY_COUNT.getAndIncrement() % 2 == 0 ? 'foo' : 'bar'");