Class PahoMqttV5TransportConnector
- java.lang.Object
-
- de.iip_ecosphere.platform.transport.connectors.impl.AbstractTransportConnector
-
- de.iip_ecosphere.platform.transport.connectors.basics.AbstractMqttTransportConnector
-
- de.iip_ecosphere.platform.transport.mqttv5.PahoMqttV5TransportConnector
-
- All Implemented Interfaces:
de.iip_ecosphere.platform.transport.connectors.TransportConnector
public class PahoMqttV5TransportConnector extends de.iip_ecosphere.platform.transport.connectors.basics.AbstractMqttTransportConnectorA MQTT v5 connector based on Eclipse Paho. RequiresTransportParameter.getApplicationId(). This implementation is potentially not thread-safe, i.e., it may require a sending queue.- Author:
- Holger Eichelberger, SSE
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classPahoMqttV5TransportConnector.CallbackThe internal reception callback.
-
Field Summary
Fields Modifier and Type Field Description private org.eclipse.paho.mqttv5.client.MqttAsyncClientclientstatic StringNAMEprivate intqosprivate booleantlsEnabled
-
Constructor Summary
Constructors Constructor Description PahoMqttV5TransportConnector()Creates a connector instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidasyncSend(String stream, Object data)voidconnect(de.iip_ecosphere.platform.transport.connectors.TransportParameter params)voiddisconnect()StringenabledEncryption()StringgetName()private voidsend(String stream, Object data, boolean block)Sendsdatatostream.voidsetReceptionCallback(String stream, de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<?> callback)StringsupportedEncryption()voidsyncSend(String stream, Object data)voidunsubscribe(String stream, boolean delete)private voidwaitForCompletion(org.eclipse.paho.mqttv5.client.IMqttToken token)Waits for completion until thetokenis processed.-
Methods inherited from class de.iip_ecosphere.platform.transport.connectors.basics.AbstractMqttTransportConnector
composeNames, composeStreamName
-
-
-
-
Field Detail
-
NAME
public static final String NAME
- See Also:
- Constant Field Values
-
client
private org.eclipse.paho.mqttv5.client.MqttAsyncClient client
-
tlsEnabled
private boolean tlsEnabled
-
qos
private int qos
-
-
Method Detail
-
connect
public void connect(de.iip_ecosphere.platform.transport.connectors.TransportParameter params) throws IOException- Specified by:
connectin interfacede.iip_ecosphere.platform.transport.connectors.TransportConnector- Overrides:
connectin classde.iip_ecosphere.platform.transport.connectors.impl.AbstractTransportConnector- Throws:
IOException
-
setReceptionCallback
public void setReceptionCallback(String stream, de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<?> callback) throws IOException
- Specified by:
setReceptionCallbackin interfacede.iip_ecosphere.platform.transport.connectors.TransportConnector- Overrides:
setReceptionCallbackin classde.iip_ecosphere.platform.transport.connectors.impl.AbstractTransportConnector- Throws:
IOException
-
unsubscribe
public void unsubscribe(String stream, boolean delete) throws IOException
- Specified by:
unsubscribein interfacede.iip_ecosphere.platform.transport.connectors.TransportConnector- Overrides:
unsubscribein classde.iip_ecosphere.platform.transport.connectors.impl.AbstractTransportConnector- Throws:
IOException
-
disconnect
public void disconnect() throws IOException- Specified by:
disconnectin interfacede.iip_ecosphere.platform.transport.connectors.TransportConnector- Overrides:
disconnectin classde.iip_ecosphere.platform.transport.connectors.impl.AbstractTransportConnector- Throws:
IOException
-
asyncSend
public void asyncSend(String stream, Object data) throws IOException
- Throws:
IOException
-
syncSend
public void syncSend(String stream, Object data) throws IOException
- Throws:
IOException
-
send
private void send(String stream, Object data, boolean block) throws IOException
Sendsdatatostream.- Parameters:
stream- the stream to send todata- the data to sendblock- shall this be a blocking or a non-blocking send operation- Throws:
IOException- in case that sending fails for some reason
-
waitForCompletion
private void waitForCompletion(org.eclipse.paho.mqttv5.client.IMqttToken token) throws org.eclipse.paho.mqttv5.common.MqttExceptionWaits for completion until thetokenis processed.- Parameters:
token- the token- Throws:
org.eclipse.paho.mqttv5.common.MqttException- in case that processing of the token fails
-
getName
public String getName()
-
supportedEncryption
public String supportedEncryption()
-
enabledEncryption
public String enabledEncryption()
-
-