/*
 * Copyright (c) 2018-2019 The original author or authors
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Apache License v2.0 which accompanies this distribution.
 *
 *        The Eclipse Public License is available at
 *        http://www.eclipse.org/legal/epl-v10.html
 *
 *        The Apache License v2.0 is available at
 *        http://www.opensource.org/licenses/apache2.0.php
 *
 * You may elect to redistribute this code under either of these licenses.
 */
package io.vertx.amqp;

import io.vertx.codegen.annotations.DataObject;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.json.JsonObject;
import io.vertx.core.net.*;
import io.vertx.proton.ProtonClientOptions;

import java.util.Set;
import java.util.UUID;

Configures the AMQP Client. You can also configure the underlying Proton instance. Refer to ProtonClientOptions for details.
/** * Configures the AMQP Client. * You can also configure the underlying Proton instance. Refer to {@link ProtonClientOptions} for details. */
@DataObject(generateConverter = true, inheritConverter = true) public class AmqpClientOptions extends ProtonClientOptions { // TODO Capabilities and properties private String host = getFromSysOrEnv("amqp-client-host"); private int port = getPortFromSysOrEnv(); private String username = getFromSysOrEnv("amqp-client-username"); private String password = getFromSysOrEnv("amqp-client-password"); private String containerId = UUID.randomUUID().toString(); public AmqpClientOptions() { super(); } public AmqpClientOptions(JsonObject json) { super(json); AmqpClientOptionsConverter.fromJson(json, this); } public AmqpClientOptions(AmqpClientOptions other) { super(other); this.host = other.host; this.password = other.password; this.username = other.username; this.port = other.port; this.containerId = other.containerId; } public JsonObject toJson() { JsonObject json = super.toJson(); AmqpClientOptionsConverter.toJson(this, json); return json; }
Returns:the host.
/** * @return the host. */
public String getHost() { return host; }
Sets the host.
Params:
  • host – the host, must not be null when the client attempt to connect. Defaults to system variable amqp-client-host and to AMQP_CLIENT_HOST environment variable
Returns:the current AmqpClientOptions
/** * Sets the host. * * @param host the host, must not be {@code null} when the client attempt to connect. Defaults to system variable * {@code amqp-client-host} and to {@code AMQP_CLIENT_HOST} environment variable * @return the current {@link AmqpClientOptions} */
public AmqpClientOptions setHost(String host) { this.host = host; return this; }
Returns:the port.
/** * @return the port. */
public int getPort() { return port; }
Sets the port.
Params:
  • port – the port, defaults to system variable amqp-client-port and to AMQP_CLIENT_PORT environment variable and if neither is set 5672.
Returns:the current AmqpClientOptions
/** * Sets the port. * * @param port the port, defaults to system variable {@code amqp-client-port} and to {@code AMQP_CLIENT_PORT} * environment variable and if neither is set {@code 5672}. * @return the current {@link AmqpClientOptions} */
public AmqpClientOptions setPort(int port) { this.port = port; return this; }
Returns:the username
/** * @return the username */
public String getUsername() { return username; }
Sets the username.
Params:
  • username – the username, defaults to system variable amqp-client-username and to AMQP_CLIENT_USERNAME environment variable.
Returns:the current AmqpClientOptions
/** * Sets the username. * * @param username the username, defaults to system variable {@code amqp-client-username} and * to {@code AMQP_CLIENT_USERNAME} environment variable. * @return the current {@link AmqpClientOptions} */
public AmqpClientOptions setUsername(String username) { this.username = username; return this; }
Returns:the password
/** * @return the password */
public String getPassword() { return password; }
Sets the password.
Params:
  • pwd – the password, defaults to system variable amqp-client-password and to AMQP_CLIENT_PASSWORD environment variable.
Returns:the current AmqpClientOptions
/** * Sets the password. * * @param pwd the password, defaults to system variable {@code amqp-client-password} and to * {@code AMQP_CLIENT_PASSWORD} environment variable. * @return the current {@link AmqpClientOptions} */
public AmqpClientOptions setPassword(String pwd) { this.password = pwd; return this; }
Returns:the container id.
/** * @return the container id. */
public String getContainerId() { return containerId; }
Sets the container id.
Params:
  • containerId – the container id
Returns:the current AmqpClientOptions
/** * Sets the container id. * * @param containerId the container id * @return the current {@link AmqpClientOptions} */
public AmqpClientOptions setContainerId(String containerId) { this.containerId = containerId; return this; }
See Also:
  • addEnabledSaslMechanism.addEnabledSaslMechanism(String)
/** * @see ProtonClientOptions#addEnabledSaslMechanism(String) */
@Override public AmqpClientOptions addEnabledSaslMechanism(String saslMechanism) { super.addEnabledSaslMechanism(saslMechanism); return this; }
See Also:
  • setSendBufferSize.setSendBufferSize(int)
/** * @see ProtonClientOptions#setSendBufferSize(int) */
@Override public AmqpClientOptions setSendBufferSize(int sendBufferSize) { super.setSendBufferSize(sendBufferSize); return this; }
See Also:
  • setReceiveBufferSize.setReceiveBufferSize(int)
/** * @see ProtonClientOptions#setReceiveBufferSize(int) */
@Override public AmqpClientOptions setReceiveBufferSize(int receiveBufferSize) { super.setReceiveBufferSize(receiveBufferSize); return this; }
See Also:
  • setReuseAddress.setReuseAddress(boolean)
/** * @see ProtonClientOptions#setReuseAddress(boolean) */
@Override public AmqpClientOptions setReuseAddress(boolean reuseAddress) { super.setReuseAddress(reuseAddress); return this; }
See Also:
  • setTrafficClass.setTrafficClass(int)
/** * @see ProtonClientOptions#setTrafficClass(int) */
@Override public AmqpClientOptions setTrafficClass(int trafficClass) { super.setTrafficClass(trafficClass); return this; }
See Also:
  • setTcpNoDelay.setTcpNoDelay(boolean)
/** * @see ProtonClientOptions#setTcpNoDelay(boolean) */
@Override public AmqpClientOptions setTcpNoDelay(boolean tcpNoDelay) { super.setTcpNoDelay(tcpNoDelay); return this; }
See Also:
  • setTcpKeepAlive.setTcpKeepAlive(boolean)
/** * @see ProtonClientOptions#setTcpKeepAlive(boolean) */
@Override public AmqpClientOptions setTcpKeepAlive(boolean tcpKeepAlive) { super.setTcpKeepAlive(tcpKeepAlive); return this; }
See Also:
  • setSoLinger.setSoLinger(int)
/** * @see ProtonClientOptions#setSoLinger(int) */
@Override public AmqpClientOptions setSoLinger(int soLinger) { super.setSoLinger(soLinger); return this; }
See Also:
  • setIdleTimeout.setIdleTimeout(int)
/** * @see ProtonClientOptions#setIdleTimeout(int) */
@Override public AmqpClientOptions setIdleTimeout(int idleTimeout) { super.setIdleTimeout(idleTimeout); return this; }
See Also:
  • setSsl.setSsl(boolean)
/** * @see ProtonClientOptions#setSsl(boolean) */
@Override public AmqpClientOptions setSsl(boolean ssl) { super.setSsl(ssl); return this; }
See Also:
  • setKeyStoreOptions.setKeyStoreOptions(JksOptions)
/** * @see ProtonClientOptions#setKeyStoreOptions(JksOptions) */
@Override public AmqpClientOptions setKeyStoreOptions(JksOptions options) { super.setKeyStoreOptions(options); return this; }
See Also:
  • setPfxKeyCertOptions.setPfxKeyCertOptions(PfxOptions)
/** * @see ProtonClientOptions#setPfxKeyCertOptions(PfxOptions) */
@Override public AmqpClientOptions setPfxKeyCertOptions(PfxOptions options) { super.setPfxKeyCertOptions(options); return this; }
See Also:
  • setPemKeyCertOptions.setPemKeyCertOptions(PemKeyCertOptions)
/** * @see ProtonClientOptions#setPemKeyCertOptions(PemKeyCertOptions) */
@Override public AmqpClientOptions setPemKeyCertOptions(PemKeyCertOptions options) { super.setPemKeyCertOptions(options); return this; }
See Also:
  • setTrustStoreOptions.setTrustStoreOptions(JksOptions)
/** * @see ProtonClientOptions#setTrustStoreOptions(JksOptions) */
@Override public AmqpClientOptions setTrustStoreOptions(JksOptions options) { super.setTrustStoreOptions(options); return this; }
See Also:
  • setPemTrustOptions.setPemTrustOptions(PemTrustOptions)
/** * @see ProtonClientOptions#setPemTrustOptions(PemTrustOptions) */
@Override public AmqpClientOptions setPemTrustOptions(PemTrustOptions options) { super.setPemTrustOptions(options); return this; }
See Also:
  • setPfxTrustOptions.setPfxTrustOptions(PfxOptions)
/** * @see ProtonClientOptions#setPfxTrustOptions(PfxOptions) */
@Override public AmqpClientOptions setPfxTrustOptions(PfxOptions options) { super.setPfxTrustOptions(options); return this; }
See Also:
  • addEnabledCipherSuite.addEnabledCipherSuite(String)
/** * @see ProtonClientOptions#addEnabledCipherSuite(String) */
@Override public AmqpClientOptions addEnabledCipherSuite(String suite) { super.addEnabledCipherSuite(suite); return this; }
See Also:
  • addCrlPath.addCrlPath(String)
/** * @see ProtonClientOptions#addCrlPath(String) */
@Override public AmqpClientOptions addCrlPath(String crlPath) { super.addCrlPath(crlPath); return this; }
See Also:
  • addCrlValue.addCrlValue(Buffer)
/** * @see ProtonClientOptions#addCrlValue(Buffer) */
@Override public AmqpClientOptions addCrlValue(Buffer crlValue) { super.addCrlValue(crlValue); return this; }
See Also:
  • setTrustAll.setTrustAll(boolean)
/** * @see ProtonClientOptions#setTrustAll(boolean) */
@Override public AmqpClientOptions setTrustAll(boolean trustAll) { super.setTrustAll(trustAll); return this; }
See Also:
  • setConnectTimeout.setConnectTimeout(int)
/** * @see ProtonClientOptions#setConnectTimeout(int) */
@Override public AmqpClientOptions setConnectTimeout(int connectTimeout) { super.setConnectTimeout(connectTimeout); return this; }
See Also:
  • setReconnectAttempts.setReconnectAttempts(int)
/** * @see ProtonClientOptions#setReconnectAttempts(int) */
@Override public AmqpClientOptions setReconnectAttempts(int attempts) { super.setReconnectAttempts(attempts); return this; }
See Also:
  • setReconnectInterval.setReconnectInterval(long)
/** * @see ProtonClientOptions#setReconnectInterval(long) */
@Override public AmqpClientOptions setReconnectInterval(long interval) { super.setReconnectInterval(interval); return this; }
See Also:
  • addEnabledSecureTransportProtocol.addEnabledSecureTransportProtocol(String)
/** * @see ProtonClientOptions#addEnabledSecureTransportProtocol(String) */
@Override public AmqpClientOptions addEnabledSecureTransportProtocol(String protocol) { super.addEnabledSecureTransportProtocol(protocol); return this; }
See Also:
  • setHostnameVerificationAlgorithm.setHostnameVerificationAlgorithm(String)
/** * @see ProtonClientOptions#setHostnameVerificationAlgorithm(String) */
@Override public AmqpClientOptions setHostnameVerificationAlgorithm(String hostnameVerificationAlgorithm) { super.setHostnameVerificationAlgorithm(hostnameVerificationAlgorithm); return this; }
See Also:
  • setJdkSslEngineOptions.setJdkSslEngineOptions(JdkSSLEngineOptions)
/** * @see ProtonClientOptions#setJdkSslEngineOptions(JdkSSLEngineOptions) */
@Override public AmqpClientOptions setJdkSslEngineOptions(JdkSSLEngineOptions sslEngineOptions) { super.setJdkSslEngineOptions(sslEngineOptions); return this; }
See Also:
  • setOpenSslEngineOptions.setOpenSslEngineOptions(OpenSSLEngineOptions)
/** * @see ProtonClientOptions#setOpenSslEngineOptions(OpenSSLEngineOptions) */
@Override public AmqpClientOptions setOpenSslEngineOptions(OpenSSLEngineOptions sslEngineOptions) { super.setOpenSslEngineOptions(sslEngineOptions); return this; }
See Also:
  • setSslEngineOptions.setSslEngineOptions(SSLEngineOptions)
/** * @see ProtonClientOptions#setSslEngineOptions(SSLEngineOptions) */
@Override public AmqpClientOptions setSslEngineOptions(SSLEngineOptions sslEngineOptions) { super.setSslEngineOptions(sslEngineOptions); return this; }
See Also:
  • setLocalAddress.setLocalAddress(String)
/** * @see ProtonClientOptions#setLocalAddress(String) */
@Override public AmqpClientOptions setLocalAddress(String localAddress) { super.setLocalAddress(localAddress); return this; }
See Also:
  • setReusePort.setReusePort(boolean)
/** * @see ProtonClientOptions#setReusePort(boolean) */
@Override public AmqpClientOptions setReusePort(boolean reusePort) { super.setReusePort(reusePort); return this; }
See Also:
  • setTcpCork.setTcpCork(boolean)
/** * @see ProtonClientOptions#setTcpCork(boolean) */
@Override public AmqpClientOptions setTcpCork(boolean tcpCork) { super.setTcpCork(tcpCork); return this; }
See Also:
  • setTcpFastOpen.setTcpFastOpen(boolean)
/** * @see ProtonClientOptions#setTcpFastOpen(boolean) */
@Override public AmqpClientOptions setTcpFastOpen(boolean tcpFastOpen) { super.setTcpFastOpen(tcpFastOpen); return this; }
See Also:
  • setTcpQuickAck.setTcpQuickAck(boolean)
/** * @see ProtonClientOptions#setTcpQuickAck(boolean) */
@Override public AmqpClientOptions setTcpQuickAck(boolean tcpQuickAck) { super.setTcpQuickAck(tcpQuickAck); return this; }
See Also:
  • removeEnabledSecureTransportProtocol.removeEnabledSecureTransportProtocol(String)
/** * @see ProtonClientOptions#removeEnabledSecureTransportProtocol(String) */
@Override public AmqpClientOptions removeEnabledSecureTransportProtocol(String protocol) { super.removeEnabledSecureTransportProtocol(protocol); return this; }
See Also:
  • setEnabledSecureTransportProtocols.setEnabledSecureTransportProtocols(Set)
/** * @see ProtonClientOptions#setEnabledSecureTransportProtocols(Set) */
@Override public AmqpClientOptions setEnabledSecureTransportProtocols(Set<String> enabledSecureTransportProtocols) { super.setEnabledSecureTransportProtocols(enabledSecureTransportProtocols); return this; }
See Also:
  • setVirtualHost.setVirtualHost(String)
/** * @see ProtonClientOptions#setVirtualHost(String) */
@Override public AmqpClientOptions setVirtualHost(String virtualHost) { super.setVirtualHost(virtualHost); return this; }
See Also:
  • setSniServerName.setSniServerName(String)
/** * @see ProtonClientOptions#setSniServerName(String) */
@Override public AmqpClientOptions setSniServerName(String sniServerName) { super.setSniServerName(sniServerName); return this; }
See Also:
  • setHeartbeat.setHeartbeat(int)
/** * @see ProtonClientOptions#setHeartbeat(int) */
@Override public AmqpClientOptions setHeartbeat(int heartbeat) { super.setHeartbeat(heartbeat); return this; }
See Also:
  • setMaxFrameSize.setMaxFrameSize(int)
/** * @see ProtonClientOptions#setMaxFrameSize(int) */
@Override public AmqpClientOptions setMaxFrameSize(int maxFrameSize) { super.setMaxFrameSize(maxFrameSize); return this; } private String getFromSysOrEnv(String key) { String sys = System.getProperty(key); if (sys == null) { return System.getenv(key.toUpperCase().replace("-", "_")); } return sys; } private int getPortFromSysOrEnv() { String s = getFromSysOrEnv("amqp-client-port"); if (s == null) { return 5672; } else { return Integer.parseInt(s); } } }