Package org.springframework.amqp.rabbit.connection

Examples of org.springframework.amqp.rabbit.connection.AbstractRoutingConnectionFactory


    }, obtainTargetConnectionFactoryIfNecessary(this.sendConnectionFactorySelectorExpression, message));
  }

  private ConnectionFactory obtainTargetConnectionFactoryIfNecessary(Expression expression, Object rootObject) {
    if (expression != null && getConnectionFactory() instanceof AbstractRoutingConnectionFactory) {
      AbstractRoutingConnectionFactory routingConnectionFactory =
          (AbstractRoutingConnectionFactory) getConnectionFactory();
      Object lookupKey = null;
      if (rootObject != null) {
        lookupKey = this.sendConnectionFactorySelectorExpression.getValue(this.evaluationContext, rootObject);
      }
      else {
        lookupKey = this.sendConnectionFactorySelectorExpression.getValue(this.evaluationContext);
      }
      if (lookupKey != null) {
        ConnectionFactory connectionFactory = routingConnectionFactory.getTargetConnectionFactory(lookupKey);
        if (connectionFactory != null) {
          return connectionFactory;
        }
        else if (!routingConnectionFactory.isLenientFallback()) {
          throw new IllegalStateException("Cannot determine target ConnectionFactory for lookup key ["
              + lookupKey + "]");
        }
      }
    }
View Full Code Here


        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'");
View Full Code Here

TOP

Related Classes of org.springframework.amqp.rabbit.connection.AbstractRoutingConnectionFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.