Package com.rabbitmq.client

Examples of com.rabbitmq.client.Address


   * Returns an array of Addresses for the {@code hosts} and {@code port}.
   */
  public static Address[] addressesFor(String[] hosts, int port) {
    Address[] hostAddresses = new Address[hosts.length];
    for (int i = 0; i < hosts.length; i++)
      hostAddresses[i] = new Address(hosts[i].trim(), port);
    return hostAddresses;
  }
View Full Code Here


        List<Address> addresses = new ArrayList<Address>();
        for (String key : configuration.getKeys(RABBITMQ_ADDR_PREFIX)) {
            if (key.endsWith(".host")) {
                String host = configuration.get(key);
                int port = configuration.getInt(key.replace(".host", ".port"), DEFAULT_PORT);
                addresses.add(new Address(host, port));
            }
        }
        return addresses.toArray(new Address[addresses.size()]);
    }
View Full Code Here

   
    @Test
    public void brokerEndpointAddressesSettings() throws Exception {
        RabbitMQEndpoint endpoint = context.getEndpoint("rabbitmq:localhost/exchange?addresses=server1:12345,server2:12345", RabbitMQEndpoint.class);
        assertEquals("Wrong size of endpoint addresses.", 2, endpoint.getAddresses().length);
        assertEquals("Get a wrong endpoint address.", new Address("server1", 12345), endpoint.getAddresses()[0]);
        assertEquals("Get a wrong endpoint address.", new Address("server2", 12345), endpoint.getAddresses()[1]);
    }
View Full Code Here

   
    @Test
    public void brokerEndpointAddressesSettings() throws Exception {
        RabbitMQEndpoint endpoint = context.getEndpoint("rabbitmq:localhost/exchange?addresses=server1:12345,server2:12345", RabbitMQEndpoint.class);
        assertEquals("Wrong size of endpoint addresses.", 2, endpoint.getAddresses().length);
        assertEquals("Get a wrong endpoint address.", new Address("server1", 12345), endpoint.getAddresses()[0]);
        assertEquals("Get a wrong endpoint address.", new Address("server2", 12345), endpoint.getAddresses()[1]);
    }
View Full Code Here

      return addresses;

    if (hosts != null) {
      addresses = new Address[hosts.length];
      for (int i = 0; i < hosts.length; i++)
        addresses[i] = new Address(hosts[i], factory.getPort());
      return addresses;
    }

    Address address = factory == null ? new Address("localhost", -1) : new Address(
        factory.getHost(), factory.getPort());
    return new Address[] { address };
  }
View Full Code Here

    @Test
    public void brokerEndpointAddressesSettings() throws Exception {
        RabbitMQEndpoint endpoint = context.getEndpoint("rabbitmq:localhost/exchange?addresses=server1:12345,server2:12345", RabbitMQEndpoint.class);
        assertEquals("Wrong size of endpoint addresses.", 2, endpoint.getAddresses().length);
        assertEquals("Get a wrong endpoint address.", new Address("server1", 12345), endpoint.getAddresses()[0]);
        assertEquals("Get a wrong endpoint address.", new Address("server2", 12345), endpoint.getAddresses()[1]);
    }
View Full Code Here

    public void onReconnection(final HaConnectionProxy connectionProxy) {

        // use a separate connection and channel to avoid race conditions with any operations that are blocked
        // waiting for the reconnection to finish...and don't cache anything otherwise you get the same problem!
        try {
            Connection connection = connectionFactory.newConnection(new Address[] { new Address(host) });
            Channel channel = connection.createChannel();

            channel.queueDeclare("testQueue", false, false, false, new HashMap<String, Object>());
            channel.queueBind("testQueue", "amq.topic", "#");
View Full Code Here

         * @return
         */
        public Address[] getAddress(String seeds) {
            List<Address> addresses = new ArrayList<>();
            if (seeds == null || seeds.isEmpty()) {
                addresses.add(new Address("localhost", 5672));
                return addresses.toArray(new Address[0]);
            }
            String[] stringArray = seeds.split("[;,\\s]");
            for (String s : stringArray) {
                String[] hostPort = s.split(":");
                if (0 == hostPort.length) {
                    continue;
                }
                String host = hostPort[0];
                int port = 5672;
                if (hostPort.length > 1) {
                    port = Integer.parseInt(hostPort[1]);
                }
                addresses.add(new Address(host, port));
            }
            return addresses.toArray(new Address[0]);
        }
View Full Code Here

TOP

Related Classes of com.rabbitmq.client.Address

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.