Package org.springframework.amqp.rabbit.connection

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


  }

  @Test
  public void testRabbitTemplateVirtualHostMultiLeadingSlashes() {
    load(TestConfiguration.class, "spring.rabbitmq.virtual_host:///foo");
    CachingConnectionFactory connectionFactory = this.context
        .getBean(CachingConnectionFactory.class);
    assertEquals("///foo", connectionFactory.getVirtualHost());
  }
View Full Code Here


  }

  @Test
  public void testRabbitTemplateDefaultVirtualHost() {
    load(TestConfiguration.class, "spring.rabbitmq.virtual_host:/");
    CachingConnectionFactory connectionFactory = this.context
        .getBean(CachingConnectionFactory.class);
    assertEquals("/", connectionFactory.getVirtualHost());
  }
View Full Code Here

  @Test
  public void testConnectionFactoryBackOff() {
    load(TestConfiguration2.class);
    RabbitTemplate rabbitTemplate = this.context.getBean(RabbitTemplate.class);
    CachingConnectionFactory connectionFactory = this.context
        .getBean(CachingConnectionFactory.class);
    assertEquals(rabbitTemplate.getConnectionFactory(), connectionFactory);
    assertEquals("otherserver", connectionFactory.getHost());
    assertEquals(8001, connectionFactory.getPort());
  }
View Full Code Here

  @Configuration
  protected static class TestConfiguration2 {
    @Bean
    ConnectionFactory aDifferentConnectionFactory() {
      return new CachingConnectionFactory("otherserver", 8001);
    }
View Full Code Here

  public ConnectionFactory connectionFactory() {
    CloudEnvironment environment = new CloudEnvironment();
    if (environment.getInstanceInfo() != null) {
      return new RabbitServiceCreator(new CloudEnvironment()).createSingletonService().service;
    } else {
      CachingConnectionFactory connectionFactory = new CachingConnectionFactory("localhost");
      connectionFactory.setUsername("guest");
      connectionFactory.setPassword("guest");
      return connectionFactory;
    }
  }
View Full Code Here

  public ConnectionFactory connectionFactory() {
    CloudEnvironment environment = new CloudEnvironment();   
    if (environment.getInstanceInfo() != null) {
      return new RabbitServiceCreator(new CloudEnvironment()).createSingletonService().service;
    } else {
      CachingConnectionFactory connectionFactory = new CachingConnectionFactory("localhost");
      connectionFactory.setUsername("guest");
      connectionFactory.setPassword("guest");
      return connectionFactory;
    }
  }
View Full Code Here

            ampqUrl = new URI(getEnvOrThrow("CLOUDAMQP_URL"));
        } catch (URISyntaxException e) {
            throw new RuntimeException(e);
        }

        final CachingConnectionFactory factory = new CachingConnectionFactory();
        factory.setUsername(ampqUrl.getUserInfo().split(":")[0]);
        factory.setPassword(ampqUrl.getUserInfo().split(":")[1]);
        factory.setHost(ampqUrl.getHost());
        factory.setPort(ampqUrl.getPort());
        factory.setVirtualHost(ampqUrl.getPath().substring(1));

        return factory;
    }
View Full Code Here

      String virtualHost = (args.hasOption("v") ? args.getOptionValue("v") : props.getProperty("mq.virtualhost", "/"));
      String host = (args.hasOption("h") ? args.getOptionValue("h") : props.getProperty("mq.host", "localhost"));
      int port = Integer.parseInt(args.hasOption("p") ? args.getOptionValue("p") : props.getProperty("mq.port",
                                                                                                     "5672"));

      CachingConnectionFactory connectionFactory = new CachingConnectionFactory(host);
      connectionFactory.setPort(port);
      connectionFactory.setUsername(username);
      connectionFactory.setPassword(password);
      if (null != virtualHost) {
        connectionFactory.setVirtualHost(virtualHost);
      }

      // The DSL builder
      RabbitMQBuilder builder = new RabbitMQBuilder();
      builder.setConnectionFactory(connectionFactory);
View Full Code Here

    public static final String DEFAULT_CONNECTION = "DefaultConnection";
    public static final String CONNECTION = "connection";
    public static final String EXCHANGE_NAME_HEADER = "EXCHANGE_NAME";
   
    public SpringAMQPComponent() {
        this(new CachingConnectionFactory());
    }
View Full Code Here

        if(this.amqpAdministration == null && getCamelContext() != null && getCamelContext().getRegistry() != null) {
            //Attempt to load an administration connection from the registry
            this.amqpAdministration = new HashMap<String, AmqpAdmin>();
            Map<String, AmqpAdmin> adminMap = getCamelContext().getRegistry().findByTypeWithName(AmqpAdmin.class);
            for(AmqpAdmin admin : adminMap.values()){
                CachingConnectionFactory adminConnection = (CachingConnectionFactory)((RabbitAdmin)admin).getRabbitTemplate().getConnectionFactory();
                for(Map.Entry<String, ConnectionFactory> connection : this.connectionFactory.entrySet()){
                    if(identicalConnectionFactories(adminConnection, connection.getValue())){
                        this.amqpAdministration.put(connection.getKey(), admin);
                        break;
                    }
View Full Code Here

TOP

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

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.