public class IotDevicePubSub extends java.lang.Object
IotDeviceacross multiple running jobs. This allows a single connection to a back-end message hub to be shared across multiple independent applications, without having to build a single topology.
Applications coded to
IotDevice obtain a topology specific
addIotDevice(TopologyElement). This returned
device will route events and commands to/from the actual message hub
IotDevice through publish-subscribe.
An instance of this application is created by first creating a new topology and
then creating a
IotDevice specific to the desired message hub. Then
the application is created by calling
Then additional independent applications (topologies) can be created and they create a proxy
IotDevice for their topology using
addIotDevice(TopologyElement). This proxy
IotDevice is then
used to send device events and receive device commands in that topology.
Once all the topologies have been declared they can be submitted.
At startup this application sends a single device event with
Events.IOT_START. This performs two functions:
|Modifier and Type||Field and Description|
IotDevicePubSub application name.
Device commands are published to "edgent/iot/commands" by this application.
Events published to topic "edgent/iot/events" are sent as device events using the actual message hub
|Constructor and Description|
|Modifier and Type||Method and Description|
Add a proxy
Create an instance of this application using
public static final java.lang.String APP_NAME
public static final java.lang.String EVENTS_TOPIC
addIotDevice(TopologyElement)to send events rather than publishing streams to this topic.
public static final java.lang.String COMMANDS_TOPIC
addIotDevice(TopologyElement)to receive commands rather than subscribing to streams with this topic prefix.
public static void createApplication(IotDevice device)
deviceas the device connection to a message hub.
device- the IotDevice
public static IotDevice addIotDevice(TopologyElement te)
IotDevicefor the topology containing
Any events sent through the returned device are sent onto the message hub
device through publish-subscribe.
Subscribing to commands using the returned device will subscribe to commands received by the message hub device.
te- Topology the returned device is contained in.
Copyright © 2017 The Apache Software Foundation. All Rights Reserved - 4744f56-20170226-1707