You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@edgent.apache.org by dj...@apache.org on 2016/04/04 17:14:30 UTC
[2/6] incubator-quarks git commit: Send event at startup
Send event at startup
Project: http://git-wip-us.apache.org/repos/asf/incubator-quarks/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quarks/commit/c2ecdccc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quarks/tree/c2ecdccc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quarks/diff/c2ecdccc
Branch: refs/heads/master
Commit: c2ecdccc1d6e22f528c93aec70550342864fb255
Parents: 0fd68f9
Author: Dan Debrunner <dj...@debrunners.com>
Authored: Sat Apr 2 09:16:26 2016 -0700
Committer: Dan Debrunner <dj...@debrunners.com>
Committed: Sat Apr 2 09:16:26 2016 -0700
----------------------------------------------------------------------
.../main/java/quarks/apps/iot/IotDevicePubSub.java | 15 +++++++++++++++
1 file changed, 15 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-quarks/blob/c2ecdccc/apps/iot/src/main/java/quarks/apps/iot/IotDevicePubSub.java
----------------------------------------------------------------------
diff --git a/apps/iot/src/main/java/quarks/apps/iot/IotDevicePubSub.java b/apps/iot/src/main/java/quarks/apps/iot/IotDevicePubSub.java
index 46d2444..188cfc3 100644
--- a/apps/iot/src/main/java/quarks/apps/iot/IotDevicePubSub.java
+++ b/apps/iot/src/main/java/quarks/apps/iot/IotDevicePubSub.java
@@ -21,7 +21,9 @@ package quarks.apps.iot;
import com.google.gson.JsonObject;
+import quarks.connectors.iot.Events;
import quarks.connectors.iot.IotDevice;
+import quarks.connectors.iot.QoS;
import quarks.connectors.pubsub.PublishSubscribe;
import quarks.topology.TStream;
import quarks.topology.TopologyElement;
@@ -48,6 +50,15 @@ import quarks.topology.TopologyElement;
* used to send device events and receive device commands in that topology. <BR>
* Once all the topologies have been declared they can be submitted.
* </P>
+ * <P>
+ * At startup this application sends a single device event with
+ * identifier {@link Events#IOT_START}. This performs two functions:
+ * <UL>
+ * <LI>Initiates a connection to the message hub.</LI>
+ * <LI>Allows external applications to be notified (by subscribing to device events)
+ * when a Quarks provider starts.</LI>
+ * </UL>
+ * </P>
*
* @see PublishSubscribe
*/
@@ -88,6 +99,10 @@ public class IotDevicePubSub {
ew -> ew.getAsJsonPrimitive("qos").getAsInt());
PublishSubscribe.publish(device.commands(), COMMANDS_TOPIC, JsonObject.class);
+
+ // Publish a single event at startup
+ TStream<JsonObject> start = device.topology().of(new JsonObject());
+ device.events(start, Events.IOT_START, QoS.AT_MOST_ONCE);
}
/**