public class Broker extends java.lang.Object implements java.lang.Comparable<Broker>, java.lang.Cloneable
Broker represents a DXL message broker.
Instances of this class are created for the purpose of connecting to the DXL fabric.
There are a couple of ways to create Broker instances:
Broker constructor directlyDxlClientConfig object via the DxlClientConfig.createDxlConfigFromFile(java.lang.String)
static method| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
FIELD_SEPARATOR
Constant for parse separator
|
static java.lang.String |
SSL_PROTOCOL
Constant for ssl protocol
|
static java.lang.String |
WSS_PROTOCOL
The WSS protocol identifier
|
| Constructor and Description |
|---|
Broker(java.lang.String uniqueId,
int port,
java.lang.String hostName,
java.lang.String ipAddress)
Constructor for the
Broker |
Broker(java.lang.String uniqueId,
int port,
java.lang.String hostName,
java.lang.String ipAddress,
boolean useWebSockets)
Constructor for the
Broker |
| Modifier and Type | Method and Description |
|---|---|
Broker |
clone()
Creates a clone of the
Broker |
int |
compareTo(Broker that) |
boolean |
equals(java.lang.Object obj) |
java.lang.String |
getHostName()
Returns the host name or IP address of the broker
|
java.lang.String |
getIpAddress()
Returns a valid IP address for the broker.
|
int |
getPort()
Returns the port of the broker
|
java.lang.String |
getProtocol()
Returns the connection protocol of the broker.
|
java.lang.Long |
getResponseTime()
Returns the response time for the broker (essentially the ping time)
|
java.lang.String |
getUniqueId()
Returns a unique identifier for the broker, used to identify the broker in log messages, etc.
|
int |
hashCode() |
boolean |
isResponseFromIpAddress()
Returns whether the response time is for the broker's IP address
|
static Broker |
parse(java.lang.String configString)
Constructs and returns a
Broker for the specified configuration string of the following format: |
static Broker |
parse(java.lang.String configString,
boolean useWebSockets)
Constructs and returns a
Broker for the specified configuration string of the following format: |
static Broker |
parse(java.lang.String configString,
java.lang.String protocol)
Constructs and returns a
Broker for the specified protocol and configuration string of the
following format: |
void |
setHostName(java.lang.String hostName)
Sets the host name or IP address of the broker
|
void |
setIpAddress(java.lang.String ipAddress)
Sets the IP address for the broker
|
void |
setPort(int port)
Set the port of the broker
|
void |
setProtocol(java.lang.String protocol)
Set the connection protocol of the broker.
|
void |
setUniqueId(java.lang.String uniqueId)
Sets the unique identifier for the broker, used to identify the broker in log messages, etc.
|
java.lang.String |
toString() |
public static final java.lang.String SSL_PROTOCOL
public static final java.lang.String WSS_PROTOCOL
public static final java.lang.String FIELD_SEPARATOR
public Broker(java.lang.String uniqueId,
int port,
java.lang.String hostName,
java.lang.String ipAddress)
BrokeruniqueId - A unique identifier for the broker, used to identify the broker in log messages, etc.port - The port of the brokerhostName - The host name or IP address of the broker (required)ipAddress - A valid IP address for the broker. This allows for both the host name and IP address to be
used when connecting to the broker (optional).public Broker(java.lang.String uniqueId,
int port,
java.lang.String hostName,
java.lang.String ipAddress,
boolean useWebSockets)
BrokeruniqueId - A unique identifier for the broker, used to identify the broker in log messages, etc.port - The port of the brokerhostName - The host name or IP address of the broker (required)ipAddress - A valid IP address for the broker. This allows for both the host name and IP address to be
used when connecting to the broker (optional).useWebSockets - Whether to use WebSockets or regular MQTT over tcp when connecting to a brokerpublic Broker clone() throws java.lang.CloneNotSupportedException
Brokerclone in class java.lang.ObjectBrokerjava.lang.CloneNotSupportedExceptionpublic java.lang.String toString()
toString in class java.lang.Objectpublic int compareTo(Broker that)
compareTo in interface java.lang.Comparable<Broker>public java.lang.String getUniqueId()
public void setUniqueId(java.lang.String uniqueId)
uniqueId - The unique identifier for the broker, used to identify the broker in log messages, etc.public java.lang.String getHostName()
public void setHostName(java.lang.String hostName)
hostName - The host name or IP address of the brokerpublic java.lang.String getIpAddress()
public void setIpAddress(java.lang.String ipAddress)
ipAddress - The IP address for the brokerpublic java.lang.String getProtocol()
public void setProtocol(java.lang.String protocol)
protocol - The connection protocol of the broker (wss or ssl).public int getPort()
public void setPort(int port)
port - The port of the brokerpublic java.lang.Long getResponseTime()
public boolean isResponseFromIpAddress()
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic static Broker parse(java.lang.String configString) throws MalformedBrokerException
Broker for the specified configuration string of the following format:
[UniqueId];[Port];[HostName];[IpAddress]
configString - The configuration stringBroker corresponding to the specified configuration stringMalformedBrokerException - If the format is malformedpublic static Broker parse(java.lang.String configString, java.lang.String protocol) throws MalformedBrokerException
Broker for the specified protocol and configuration string of the
following format:
[UniqueId];[Port];[HostName];[IpAddress]
configString - The configuration stringprotocol - The protocol to use when connecting to a brokerBroker corresponding to the specified configuration string and protocolMalformedBrokerException - If the format is malformedpublic static Broker parse(java.lang.String configString, boolean useWebSockets) throws MalformedBrokerException
Broker for the specified configuration string of the following format:
[UniqueId];[Port];[HostName];[IpAddress]
configString - The configuration stringuseWebSockets - Whether to use WebSockets or regular MQTT over tcp when connecting to a brokerBroker corresponding to the specified configuration stringMalformedBrokerException - If the format is malformed