public class IotDevicePubSub
extends java.lang.Object
IotDevice
through publish-subscribe. IotDevice
across 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
IotDevice
using 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 createApplication(IotDevice)
passing the IotDevice
.
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
identifier Events.IOT_START
. This performs two functions:
PublishSubscribe
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
APP_NAME
IotDevicePubSub application name.
|
static java.lang.String |
COMMANDS_TOPIC
Device commands are published to "edgent/iot/commands" by
this application.
|
static java.lang.String |
EVENTS_TOPIC
Events published to topic "edgent/iot/events" are sent as device events using the
actual message hub
IotDevice . |
Constructor and Description |
---|
IotDevicePubSub() |
Modifier and Type | Method and Description |
---|---|
static IotDevice |
addIotDevice(TopologyElement te)
Add a proxy
IotDevice for the topology containing te . |
static void |
createApplication(IotDevice device)
Create an instance of this application using
device as the device
connection to a message hub. |
public static final java.lang.String APP_NAME
public static final java.lang.String EVENTS_TOPIC
IotDevice
. IotDevice
returned by
addIotDevice(TopologyElement)
to send events rather than
publishing streams to this topic.public static final java.lang.String COMMANDS_TOPIC
IotDevice
returned by
addIotDevice(TopologyElement)
to receive commands rather than
subscribing to streams with this topic prefix.public static void createApplication(IotDevice device)
device
as the device
connection to a message hub.device
- the IotDevicepublic static IotDevice addIotDevice(TopologyElement te)
IotDevice
for the topology containing te
.
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 © 2016 The Apache Software Foundation. All Rights Reserved - bbe71fa-20161201-1641