com.rabbitmq.client.Address.getHost()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(99)

本文整理了Java中com.rabbitmq.client.Address.getHost()方法的一些代码示例,展示了Address.getHost()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address.getHost()方法的具体详情如下:
包路径:com.rabbitmq.client.Address
类名称:Address
方法名:getHost

Address.getHost介绍

暂无

代码示例

代码示例来源:origin: pmq/rabbitmq-oracle-stored-procedures

@Override
public String toString() {
  StringBuilder builder = new StringBuilder();
  builder.append(this.username);
  builder.append('@');
  builder.append(this.address.getHost());
  builder.append(':');
  builder.append(this.address.getPort());
  builder.append(this.vhost);
  return builder.toString();
}

代码示例来源:origin: spring-cloud/spring-cloud-connectors

private void assertConnectorPropertiesMatchHosts(ConnectionFactory connector, List<String> uriStrings) throws Exception {
    Address[] addresses = (Address[]) ReflectionTestUtils.getField(connector, "addresses");
    assertNotNull(addresses);
    assertEquals(uriStrings.size(), addresses.length);

    for (int i = 0; i < uriStrings.size(); i++) {
      URI uri = new URI(uriStrings.get(i));
      assertEquals(uri.getHost(), addresses[i].getHost());
      assertEquals(uri.getPort(), addresses[i].getPort());
    }
  }
}

代码示例来源:origin: pmq/rabbitmq-oracle-stored-procedures

private static Connection openConnection(FullAddress address) throws IOException {
  Connection connection = null;
  if (ENABLE_DEBUG) {
    System.err.println("trying to connect to " + address);
  }
  ConnectionFactory connectionFactory = new ConnectionFactory();
  connectionFactory.setHost(address.address.getHost());
  connectionFactory.setPort(address.address.getPort());
  connectionFactory.setUsername(address.username);
  connectionFactory.setPassword(address.password);
  connectionFactory.setVirtualHost(address.vhost);
  connectionFactory.setConnectionTimeout(CONNECTION_OPEN_TIMEOUT);
  // try to open the connection
  connection = connectionFactory.newConnection();
  if (ENABLE_DEBUG) {
    System.err.println("connected to " + address);
  }
  return connection;
}

代码示例来源:origin: spring-projects/spring-amqp

@Test
public void testMultiHost() throws Exception {
  CachingConnectionFactory connectionFactory = beanFactory.getBean("multiHost", CachingConnectionFactory.class);
  assertNotNull(connectionFactory);
  assertEquals(10, connectionFactory.getChannelCacheSize());
  DirectFieldAccessor dfa =  new DirectFieldAccessor(connectionFactory);
  Address[] addresses = (Address[]) dfa.getPropertyValue("addresses");
  assertEquals(3, addresses.length);
  assertEquals("host1", addresses[0].getHost());
  assertEquals(1234, addresses[0].getPort());
  assertEquals("host2", addresses[1].getHost());
  assertEquals(-1, addresses[1].getPort());
  assertEquals("host3", addresses[2].getHost());
  assertEquals(4567, addresses[2].getPort());
  assertSame(beanFactory.getBean("tf"), TestUtils.getPropertyValue(connectionFactory,
      "rabbitConnectionFactory.threadFactory"));
}

相关文章