Using subscriptions
The com.apama.cumulocity.SubscribeMeasurements and com.apama.cumulocity.UnsubscribeMeasurements events control subscriptions to measurements from assets. Specify the asset identifier as either an asset identifier from a device event or as "*" for a wildcard (use the WILDCARD constant). Subscriptions are reference counted by the transport, so send as many unsubscribe events as subscribe events have been sent to completely unsubscribe. Unless the subscribeToMeasurements configuration property is false, the transport automatically subscribes as if SubscribeMeasurements("*") had been sent at applicationInitialized time. Subscriptions to measurements also subscribe to events and alarms.
To gain fine-grained control on the subscriptions, you can also use the com.apama.cumulocity.Subscribe and com.apama.cumulocity.Unsubscribe events. These allow you to individually subscribe to and unsubscribe from alarms, events, managed objects, measurements, or operations:
To subscribe:
send com.apama.cumulocity.Subscribe("<STREAM_NAME>", "<SUBSCRIPTION>",
new dictionary<string, any>) to com.apama.cumulocity.Subscribe.CHANNEL;
Where
<STREAM_NAME> can be one of the following:
measurements events alarms operations managedObjects <SUBSCRIPTION> can be
"*" for a wildcard (use the
WILDCARD constant) or the asset identifier from a device event.
To unsubscribe:
send com.apama.cumulocity.Unsubscribe("<STREAM_NAME>", "<SUBSCRIPTION>",
new dictionary<string, any>) to com.apama.cumulocity.Unsubscribe.CHANNEL;