本文整理了Java中com.rabbitmq.client.Address.<init>()
方法的一些代码示例,展示了Address.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address.<init>()
方法的具体详情如下:
包路径:com.rabbitmq.client.Address
类名称:Address
方法名:<init>
暂无
代码示例来源: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: 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: de.digitalcollections.flusswerk/dc-flusswerk-engine
@Override
public List<Address> getAddresses() {
if (addresses.isEmpty()) {
return Collections.singletonList(new Address("localhost", 5672));
}
return addresses;
}
}
代码示例来源:origin: de.digitalcollections.flusswerk/dc-flusswerk-engine
public void addAddress(String host, int port) {
addresses.add(new Address(host, port));
}
代码示例来源:origin: de.digitalcollections.workflow/dc-workflow-engine
public void addAddress(String host, int port) {
addresses.add(new Address(host, port));
}
代码示例来源: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: 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 };
}
代码示例来源:origin: pmq/rabbitmq-oracle-stored-procedures
String password = results.getString(5);
FullAddress currAddress = new FullAddress(new Address(host, port), vhost, username,
password);
connectionState.addresses.add(currAddress);
代码示例来源:origin: rabbitmq/rabbitmq-jms-client
/**
* {@inheritDoc}
*/
@Override
public Connection createConnection(String username, String password) throws JMSException {
if (this.uris == null || this.uris.isEmpty()) {
return createConnection(username, password, cf -> cf.newConnection());
} else {
List<Address> addresses = this.uris.stream().map(uri -> {
String host = uri.getHost();
int port = uri.getPort();
if (port == -1) {
port = isSsl() ? DEFAULT_RABBITMQ_SSL_PORT :
DEFAULT_RABBITMQ_PORT;
}
return new Address(host, port);
}).collect(Collectors.toList());
return createConnection(username, password, cf -> cf.newConnection(addresses));
}
}
代码示例来源:origin: yanghua/banyan
com.rabbitmq.client.Address address = new com.rabbitmq.client.Address(
hostPortArr[0], Integer.parseInt(hostPortArr[1])
);
代码示例来源:origin: org.apache.axis2.transport/axis2-transport-rabbitmq-amqp
if (!hostNames[i].isEmpty() && !portValues[i].isEmpty()) {
try {
addresses[i] = new Address(hostNames[i].trim(), Integer.parseInt(portValues[i].trim()));
} catch (NumberFormatException e) {
handleException("Number format error in port number", e);
代码示例来源:origin: yanghua/banyan
com.rabbitmq.client.Address address = new com.rabbitmq.client.Address(
hostPortArr[0], Integer.parseInt(hostPortArr[1])
);
代码示例来源:origin: org.apache.james/apache-james-backends-rabbitmq
public Address address() {
return new Address(getHostIp(), getPort());
}
代码示例来源:origin: spring-projects/spring-amqp
@Test
public void setAddressesTwoHosts() throws Exception {
ConnectionFactory mock = mock(com.rabbitmq.client.ConnectionFactory.class);
doReturn(true).when(mock).isAutomaticRecoveryEnabled();
CachingConnectionFactory ccf = new CachingConnectionFactory(mock);
ccf.setAddresses("mq1,mq2");
ccf.createConnection();
verify(mock).isAutomaticRecoveryEnabled();
verify(mock).setAutomaticRecoveryEnabled(false);
verify(mock).newConnection(isNull(),
aryEq(new Address[] { new Address("mq1"), new Address("mq2") }), anyString());
verifyNoMoreInteractions(mock);
}
代码示例来源:origin: spring-projects/spring-amqp
@Test
public void setAddressesOneHost() throws Exception {
ConnectionFactory mock = mock(com.rabbitmq.client.ConnectionFactory.class);
CachingConnectionFactory ccf = new CachingConnectionFactory(mock);
ccf.setAddresses("mq1");
ccf.createConnection();
verify(mock).isAutomaticRecoveryEnabled();
verify(mock)
.newConnection(isNull(), aryEq(new Address[] { new Address("mq1") }), anyString());
verifyNoMoreInteractions(mock);
}
代码示例来源:origin: vert-x3/vertx-rabbitmq-client
private static Connection newConnection(RabbitMQOptions config) throws IOException, TimeoutException {
ConnectionFactory cf = new ConnectionFactory();
String uri = config.getUri();
// Use uri if set, otherwise support individual connection parameters
List<Address> addresses = null;
if (uri != null) {
try {
cf.setUri(uri);
} catch (Exception e) {
throw new IllegalArgumentException("Invalid rabbitmq connection uri " + uri);
}
} else {
cf.setUsername(config.getUser());
cf.setPassword(config.getPassword());
addresses = config.getAddresses().isEmpty()
? Collections.singletonList(new Address(config.getHost(), config.getPort()))
: config.getAddresses();
cf.setVirtualHost(config.getVirtualHost());
}
cf.setConnectionTimeout(config.getConnectionTimeout());
cf.setRequestedHeartbeat(config.getRequestedHeartbeat());
cf.setHandshakeTimeout(config.getHandshakeTimeout());
cf.setRequestedChannelMax(config.getRequestedChannelMax());
cf.setNetworkRecoveryInterval(config.getNetworkRecoveryInterval());
cf.setAutomaticRecoveryEnabled(config.isAutomaticRecoveryEnabled());
//TODO: Support other configurations
return addresses == null
? cf.newConnection()
: cf.newConnection(addresses);
}
内容来源于网络,如有侵权,请联系作者删除!