Examples of CachingConnectionFactory


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

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

  }

  @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

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

  @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

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

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

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

  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

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

  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

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

            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

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

      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

Examples of org.springframework.jms.connection.CachingConnectionFactory

                        container2.afterPropertiesSet();
                        container2.start();

                        assertTrue("wait for start signal", startProducer.await(20, TimeUnit.SECONDS));

                        final CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory(
                                singleConnectionFactory2);
                        final JmsTemplate template = new JmsTemplate(
                                cachingConnectionFactory);
                        final ActiveMQQueue queue = new ActiveMQQueue(
                                "testingqueue");
                        for (int i = 0; i < total; i++) {
                            template.send(queue, new MessageCreator() {

                                public Message createMessage(
                                        final Session session)
                                        throws JMSException {
                                    final TextMessage message = session
                                            .createTextMessage();
                                    message.setText("Hello World!");
                                    return message;
                                }
                            });
                        }
                        // give spring time to scale back again
                        while (container2.getActiveConsumerCount() > 1) {
                            System.out.println("active consumer count: "
                                    + container2.getActiveConsumerCount());
                            System.out.println("concurrent consumer count: "
                                    + container2.getConcurrentConsumers());
                            Thread.sleep(1000);
                        }
                        cachingConnectionFactory.destroy();
                        container2.destroy();
                    } catch (final Throwable t) {
                        t.printStackTrace();
                    }
                    return null;
View Full Code Here

Examples of org.springframework.jms.connection.CachingConnectionFactory

                container2.start();
               
               
                assertTrue("wait for start signal", startProducer.await(20, TimeUnit.SECONDS));
               
                final CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory(
                        singleConnectionFactory2);
                final JmsTemplate template = new JmsTemplate(
                        cachingConnectionFactory);
                final ActiveMQQueue queue = new ActiveMQQueue(TESTING_QUEUE);
                for (int i = 0; i < total; i++) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.