Package com.rabbitmq.client

Examples of com.rabbitmq.client.ConnectionFactory


      delegate = callWithRetries(new Callable<Connection>() {
        @Override
        public Connection call() throws IOException {
          log.info("{} connection {} to {}", recovery ? "Recovering" : "Creating", connectionName,
              options.getAddresses());
          ConnectionFactory cxnFactory = options.getConnectionFactory();
          Connection connection =
              cxnFactory.newConnection(consumerThreadPool, options.getAddresses());
          final String amqpAddress =
              String.format("%s://%s:%s/%s", cxnFactory.isSSL() ? "amqps" : "amqp",
                  connection.getAddress().getHostAddress(), connection.getPort(),
                  "/".equals(cxnFactory.getVirtualHost()) ? "" : cxnFactory.getVirtualHost());
          log.info("{} connection {} to {}", recovery ? "Recovered" : "Created", connectionName,
              amqpAddress);
          return connection;
        }
      }, recurringPolicy, recurringStats, recurringExceptions, true, false);
View Full Code Here


        }

        exchangeName = "atmosphere." + exchange;
        try {
            logger.debug("Create Connection Factory");
            connectionFactory = new ConnectionFactory();
            connectionFactory.setUsername(user);
            connectionFactory.setPassword(password);
            connectionFactory.setVirtualHost(vhost);
            connectionFactory.setHost(host);
            connectionFactory.setPort(Integer.valueOf(port));
View Full Code Here

            throw new LumifyException("Could not open channel to RabbitMQ", ex);
        }
    }

    public static Connection openConnection(Configuration configuration) throws IOException {
        ConnectionFactory factory = new ConnectionFactory();
        Address[] addresses = getAddresses(configuration);
        if (addresses.length == 0) {
            throw new LumifyException("Could not configure RabbitMQ. No addresses specified. expecting configuration parameter 'rabbitmq.addr.0.host'.");
        }
        return factory.newConnection(addresses);
    }
View Full Code Here

      System.exit(-1);
    }    

    this.factory = new ConnectionFactory[this.hostName.length];
    for(int i = 0; i<hostName.length; i++) {
      this.factory[i] = new ConnectionFactory();
      this.factory[i].setUsername(this.userName);
      this.factory[i].setPassword(this.password);
      this.factory[i].setVirtualHost(this.virtualHost);
      this.factory[i].setRequestedHeartbeat(this.heartBeat);
      this.factory[i].setConnectionTimeout(this.connectTimeout);
View Full Code Here

    this.alertRoutingKey = config.getBrokerParameter("routingkey", "noit.alerts.");
    this.alertExchangeName = config.getBrokerParameter("exchange", "noit.alerts");

    this.factory = new ConnectionFactory[this.hostName.length];
    for(int i = 0; i<hostName.length; i++) {
      this.factory[i] = new ConnectionFactory();
      this.factory[i].setUsername(this.userName);
      this.factory[i].setPassword(this.password);
      this.factory[i].setVirtualHost(this.virtualHost);
      this.factory[i].setRequestedHeartbeat(this.heartBeat);
      this.factory[i].setConnectionTimeout(this.connectTimeout);
View Full Code Here

        assertThat(graphite.getFailures()).isZero();
    }

    @Test
    public void shouldFailWhenGraphiteHostUnavailable() throws Exception {
        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setHost("some-unknown-host");

        GraphiteRabbitMQ unavailableGraphite = new GraphiteRabbitMQ(connectionFactory, "graphite");

        try {
            unavailableGraphite.connect();
View Full Code Here

            final Integer rabbitSocketTimeoutMS,
            final Integer rabbitRequestedHeartbeatInSeconds) {

        this.exchange = exchange;

        this.connectionFactory = new ConnectionFactory();

  connectionFactory.setSocketConfigurator(new DefaultSocketConfigurator() {
            @Override
            public void configure(Socket socket) throws IOException {
                super.configure(socket);
View Full Code Here

        configureConsumer(consumer);
        return consumer;
    }

    public Connection connect(ExecutorService executor) throws IOException {
        ConnectionFactory factory = new ConnectionFactory();
        factory.setUsername(getUsername());
        factory.setPassword(getPassword());
        if (getVhost() == null) {
            factory.setVirtualHost("/");
        } else {
            factory.setVirtualHost(getVhost());
        }
        factory.setHost(getHostname());
        factory.setPort(getPortNumber());
        return factory.newConnection(executor);
    }
View Full Code Here

  public void run()
  {
    Connection connection = null;
    try
    {
      ConnectionFactory factory = new ConnectionFactory();
      factory.setHost(_mqServer);
      connection = factory.newConnection();
      Channel channel = connection.createChannel();

      channel.exchangeDeclare(EXCHANGE_NAME, "topic");
      String queueName = channel.queueDeclare().getQueue();
View Full Code Here

      }
    }
    System.out.println("Sending " + count + " messages with random topic id");
   

    ConnectionFactory factory = new ConnectionFactory();
    factory.setHost(mqServer);
    Connection connection = factory.newConnection();
    Channel channel = connection.createChannel();

    channel.exchangeDeclare(EXCHANGE_NAME, "topic");

    for (int i = 0; i < count; i++)
View Full Code Here

TOP

Related Classes of com.rabbitmq.client.ConnectionFactory

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.