Apama 10.5.3 | Connecting Apama Applications to External Components | Standard Connectivity Plug-ins | The Cumulocity IoT Transport Connectivity Plug-in | Using managed objects
 
Using managed objects
 
Updating a managed object
Querying for managed objects
During application initialization (onApplicationInitialized), if the requestAllDevices configuration option is enabled, the adapter sends all device/asset related information using the com.apama.cumulocity.ManagedObject event on the com.apama.cumulocity.ManagedObject.SUBSCRIBE_CHANNEL (same as cumulocity.devices) channel. After all devices/assets have been sent, the adapter sends a com.apama.cumulocity.RequestAllDevicesComplete(-1) event.
Note:
Use of the above-mentioned requestAllDevices configuration option is deprecated. Instead users should send a RequestAllDevices event to cause the adapter to send the device events when the application is ready. This will also work for applications deployed in Cumulocity IoT directly.
Example of a device event:
com.apama.cumulocity.ManagedObject("44578836","","Device_1",
["c8y_Restart","c8y_Meassage","c8y_Relay"],
["c8y_TemperatureMeasurement","c8y_LightMeasurement"],
[],[],[],[],{},
{"c8y_IsDevice":any(dictionary<any,any>,new dictionary<any,any>),
"owner":any(string,"Cumulocity_User")})
If the subscribeToDevices configuration option is enabled (true by default), any devices added to Cumulocity IoT after application initialization will be sent to the com.apama.cumulocity.ManagedObject.SUBSCRIBE_CHANNEL channel.
To fetch a list of all existing managed objects, use the FindManagedObjects API. For more information, see Querying for managed objects.
Example
The following is a simple example of how to receive, update and send managed objects:
// Subscribe to receive all the devices from Cumulocity IoT
monitor.subscribe(ManagedObject.SUBSCRIBE_CHANNEL);

// Consume all the devices from Cumulocity IoT
on all ManagedObject() as mo {
log mo.toString() at INFO;

// Update a managed object

mo.params.add("CustomMetadata", {"metadata": "Adding custom data"});
send mo to ManagedObject.SEND_CHANNEL;

}