本文整理了Java中com.rabbitmq.client.Address
类的一些代码示例,展示了Address
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address
类的具体详情如下:
包路径:com.rabbitmq.client.Address
类名称:Address
暂无
代码示例来源:origin: jhalterman/lyra
/**
* 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;
}
}
代码示例来源:origin: org.apache.camel/camel-rabbitmq
/**
* If this option is set, camel-rabbitmq will try to create connection based
* on the setting of option addresses. The addresses value is a string which
* looks like "server1:12345, server2:12345"
*/
public void setAddresses(String addresses) {
Address[] addressArray = Address.parseAddresses(addresses);
if (addressArray.length > 0) {
this.addresses = addressArray;
}
}
代码示例来源: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: net.jodah/lyra
/**
* 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;
}
}
代码示例来源: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: org.apache.camel/camel-rabbitmq
/**
* If this option is set, camel-rabbitmq will try to create connection based
* on the setting of option addresses. The addresses value is a string which
* looks like "server1:12345, server2:12345"
*/
public void setAddresses(String addresses) {
Address[] addressArray = Address.parseAddresses(addresses);
if (addressArray.length > 0) {
this.addresses = addressArray;
}
}
代码示例来源:origin: de.digitalcollections.flusswerk/dc-flusswerk-engine
public void addAddress(String host, int port) {
addresses.add(new Address(host, port));
}
代码示例来源: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: net.jodah/lyra
/**
* Sets the {@code addresses}.
*
* @param addresses formatted as "host1[:port],host2[:port]", etc.
* @throws NullPointerException if {@code addresses} is null
*/
public ConnectionOptions withAddresses(String addresses) {
this.addresses = Address.parseAddresses(Assert.notNull(addresses, "addresses"));
return this;
}
代码示例来源:origin: de.digitalcollections.workflow/dc-workflow-engine
public void addAddress(String host, int port) {
addresses.add(new Address(host, port));
}
代码示例来源: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"));
}
代码示例来源:origin: jhalterman/lyra
/**
* Sets the {@code addresses}.
*
* @param addresses formatted as "host1[:port],host2[:port]", etc.
* @throws NullPointerException if {@code addresses} is null
*/
public ConnectionOptions withAddresses(String addresses) {
this.addresses = Address.parseAddresses(Assert.notNull(addresses, "addresses"));
return this;
}
代码示例来源:origin: de.digitalcollections.flusswerk/dc-flusswerk-engine
@Override
public List<Address> getAddresses() {
if (addresses.isEmpty()) {
return Collections.singletonList(new Address("localhost", 5672));
}
return addresses;
}
}
代码示例来源:origin: spring-projects/spring-amqp
/**
* Set addresses for clustering.
* This property overrides the host+port properties if not empty.
* @param addresses list of addresses with form "host[:port],..."
*/
public void setAddresses(String addresses) {
if (StringUtils.hasText(addresses)) {
Address[] addressArray = Address.parseAddresses(addresses);
if (addressArray.length > 0) {
this.addresses = addressArray;
if (this.publisherConnectionFactory != null) {
this.publisherConnectionFactory.setAddresses(addresses);
}
return;
}
}
this.logger.info("setAddresses() called with an empty value, will be using the host+port properties for connections");
this.addresses = null;
}
代码示例来源:origin: de.digitalcollections.workflow/dc-workflow-engine
@Override
public List<Address> getAddresses() {
if (addresses.isEmpty()) {
return Collections.singletonList(new Address("localhost", 5672));
}
return addresses;
}
}
代码示例来源:origin: org.springframework.amqp/spring-rabbit
/**
* Set addresses for clustering.
* This property overrides the host+port properties if not empty.
* @param addresses list of addresses with form "host[:port],..."
*/
public void setAddresses(String addresses) {
if (StringUtils.hasText(addresses)) {
Address[] addressArray = Address.parseAddresses(addresses);
if (addressArray.length > 0) {
this.addresses = addressArray;
if (this.publisherConnectionFactory != null) {
this.publisherConnectionFactory.setAddresses(addresses);
}
return;
}
}
this.logger.info("setAddresses() called with an empty value, will be using the host+port properties for connections");
this.addresses = null;
}
代码示例来源:origin: io.zipkin.zipkin2/zipkin-collector-rabbitmq
static Address[] convertAddresses(List<String> addresses) {
Address[] addressArray = new Address[addresses.size()];
for (int i = 0; i < addresses.size(); i++) {
String[] splitAddress = addresses.get(i).split(":");
String host = splitAddress[0];
Integer port = null;
try {
if (splitAddress.length == 2) port = Integer.parseInt(splitAddress[1]);
} catch (NumberFormatException ignore) {
}
addressArray[i] = (port != null) ? new Address(host, port) : new Address(host);
}
return addressArray;
}
}
代码示例来源:origin: ppat/storm-rabbitmq
/**
*
* @return The {@link Map} of RabbitMQ hosts, converted to the necessary
* {@link Address} array
*/
public Address[] toAddresses() {
final Address[] addresses = new Address[hostsMap.size()];
int i = 0;
for (final Entry<String, Integer> entry : hostsMap.entrySet()) {
if (entry.getKey() != null) {
addresses[i++] = entry.getValue() == null ? new Address(entry.getKey()) : new Address(entry.getKey(), entry.getValue());
}
}
return addresses;
}
代码示例来源:origin: jhalterman/lyra
/**
* Returns the addresses to attempt connections to, in round-robin order.
*
* @see #withAddresses(Address...)
* @see #withAddresses(String)
* @see #withHost(String)
* @see #withHosts(String...)
*/
public Address[] getAddresses() {
if (addresses != null)
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 };
}
代码示例来源:origin: net.jodah/lyra
/**
* Returns the addresses to attempt connections to, in round-robin order.
*
* @see #withAddresses(Address...)
* @see #withAddresses(String)
* @see #withHost(String)
* @see #withHosts(String...)
*/
public Address[] getAddresses() {
if (addresses != null)
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 };
}
内容来源于网络,如有侵权,请联系作者删除!