com.eurotech.framework.core.data.transport.mqtt
Class MqttDataTransport

java.lang.Object
  extended by com.eurotech.framework.core.data.transport.mqtt.MqttDataTransport
All Implemented Interfaces:
ConfigurableComponent, DataTransportService, org.eclipse.paho.client.mqttv3.MqttCallback

public class MqttDataTransport
extends Object
implements DataTransportService, org.eclipse.paho.client.mqttv3.MqttCallback, ConfigurableComponent


Constructor Summary
MqttDataTransport()
           
 
Method Summary
protected  void activate(org.osgi.service.component.ComponentContext componentContext, Map<String,Object> properties)
           
 void connect()
          Connects to the remote broker.
 void connectionLost(Throwable cause)
           
protected  void deactivate(org.osgi.service.component.ComponentContext componentContext)
           
 void deliveryComplete(org.eclipse.paho.client.mqttv3.IMqttDeliveryToken token)
           
 void disconnect(long quiesceTimeout)
          Disconnects from the broker.
 boolean isConnected()
          Returns true if the DataTransportService is currently connected to the remote server.
 void messageArrived(String topic, org.eclipse.paho.client.mqttv3.MqttMessage message)
           
 DataTransportToken publish(String topic, byte[] payload, int qos, boolean retain)
          Enqueues a message for publishing with the underlying transport implementation.
 void setSystemService(SystemService systemService)
           
 void subscribe(String topic, int qos)
          Subscribes to a topic on the broker.
 void unsetSystemService(SystemService systemService)
           
 void unsubscribe(String topic)
          Unsubscribes to a topic on the broker.
 void updated(Map<String,Object> properties)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MqttDataTransport

public MqttDataTransport()
Method Detail

activate

protected void activate(org.osgi.service.component.ComponentContext componentContext,
                        Map<String,Object> properties)

deactivate

protected void deactivate(org.osgi.service.component.ComponentContext componentContext)

updated

public void updated(Map<String,Object> properties)

setSystemService

public void setSystemService(SystemService systemService)

unsetSystemService

public void unsetSystemService(SystemService systemService)

connect

public void connect()
             throws EsfConnectException
Description copied from interface: DataTransportService
Connects to the remote broker. This method will block until the connection is established or a timeout occurs. The actual configuration needed to establish a connection is protocol specific (e.g. MQTT) and is exposed through the ConfigurationAdmin.

Specified by:
connect in interface DataTransportService
Throws:
EsfConnectException - the caller MAY retry connecting a later time.

isConnected

public boolean isConnected()
Description copied from interface: DataTransportService
Returns true if the DataTransportService is currently connected to the remote server.

Specified by:
isConnected in interface DataTransportService

disconnect

public void disconnect(long quiesceTimeout)
Description copied from interface: DataTransportService
Disconnects from the broker. This method will block, up to the specified duration, allowing the protocol implementation to complete delivery of in-flight messages before actually disconnecting from the broker.

Specified by:
disconnect in interface DataTransportService
Parameters:
quiesceTimeout - - timeout that will be used before forcing a disconnect

subscribe

public void subscribe(String topic,
                      int qos)
               throws EsfTimeoutException,
                      EsfException,
                      EsfNotConnectedException
Description copied from interface: DataTransportService
Subscribes to a topic on the broker. This method MAY block until the underlying protocol message (e.g. the MQTT SUBSCRIBE message) is acknowledged by the broker or a timeout occurs. This message is idempotent so the caller may safely retry subscribing. The timeout interval used by the service is configurable through the ConfigurationService.

Specified by:
subscribe in interface DataTransportService
Throws:
EsfTimeoutException - TODO
EsfException
EsfNotConnectedException - TODO

unsubscribe

public void unsubscribe(String topic)
                 throws EsfTimeoutException,
                        EsfException,
                        EsfNotConnectedException
Description copied from interface: DataTransportService
Unsubscribes to a topic on the broker. This method MAY block until the underlying protocol message (e.g. the MQTT UNSUBSCRIBE message) is acknowledged by the broker or a timeout occurs. The timeout interval used by the service is configurable through the ConfigurationService.

Specified by:
unsubscribe in interface DataTransportService
Throws:
EsfTimeoutException
EsfException
EsfNotConnectedException - TODO

publish

public DataTransportToken publish(String topic,
                                  byte[] payload,
                                  int qos,
                                  boolean retain)
                           throws EsfTooManyInflightMessagesException,
                                  EsfException,
                                  EsfNotConnectedException
Description copied from interface: DataTransportService
Enqueues a message for publishing with the underlying transport implementation. An active connection to the remote server is required.

Specified by:
publish in interface DataTransportService
Returns:
Throws:
EsfTooManyInflightMessagesException
EsfException
EsfNotConnectedException - TODO

connectionLost

public void connectionLost(Throwable cause)
Specified by:
connectionLost in interface org.eclipse.paho.client.mqttv3.MqttCallback

deliveryComplete

public void deliveryComplete(org.eclipse.paho.client.mqttv3.IMqttDeliveryToken token)
Specified by:
deliveryComplete in interface org.eclipse.paho.client.mqttv3.MqttCallback

messageArrived

public void messageArrived(String topic,
                           org.eclipse.paho.client.mqttv3.MqttMessage message)
                    throws Exception
Specified by:
messageArrived in interface org.eclipse.paho.client.mqttv3.MqttCallback
Throws:
Exception


Copyright © 2013. All Rights Reserved.