Apama 10.3.1 | Apama Documentation | Connecting Apama Applications to External Components | Standard Connectivity Plug-ins | The Cumulocity IoT Transport Connectivity Plug-in | Using events | Querying for events
 
Querying for events
To search for an event or a collection of events, send the com.apama.cumulocity.FindEvent event to Cumulocity IoT, with a unique reqId to the com.apama.cumulocity.FindEvent.CHANNEL channel.
The transport will then respond with zero or more com.apama.cumulocity.FindEventResponse events and then one com.apama.cumulocity.FindEventResponseAck event on the com.apama.cumulocity.FindEventResponse.CHANNEL channel.
Example:
integer reqId := integer.incrementCounter("CumulocityRequestId");
 
com.apama.cumulocity.FindEvent request := new com.apama.cumulocity.FindEvent;
request.reqId := reqId;
 
// Filter based on event type
request.params.add("type", "c8y_DoorOpenedEvent");
 
// Subscribe to com.apama.cumulocity.FindEventResponse.CHANNEL to listen
// for responses
monitor.subscribe(com.apama.cumulocity.FindEventResponse.CHANNEL);
 
// Listen for responses based on reqId
on all com.apama.cumulocity.FindEventResponse(reqId=reqId) as response
// Avoid listener leaks by terminating the listener on completion of the request
and not com.apama.cumulocity.FindEventResponseAck(reqId=reqId)
{
log "Received Event " + response.toString() at INFO;
}
 
// Listen for com.apama.cumulocity.FindEventResponseAck,
// this indicates that all responses have been received
on com.apama.cumulocity.FindEventResponseAck(reqId=reqId) as requestCompleted
{
log "Received all Event(s) for request " +
requestCompleted.reqId.toString() at INFO;
 
// Request is completed and we can unsubscribe from this channel
monitor.unsubscribe(com.apama.cumulocity.FindEventResponse.CHANNEL);
}
 
// Send request to find available events
send request to com.apama.cumulocity.FindEvent.CHANNEL;
Supported query parameters
You can provide the following query parameters with the request:
Parameter
Description
id
Search for an event based on eventId. When searching for an event based on Id, all the query parameters listed below are ignored.
source
Search for events based on the device identifier or asset identifier of the source.
type
Search for events based on the type.
fromDate
Search for events from a start date. The date and time is provided as seconds since the epoch.
toDate
Search for events within a time range. This is to be used in combination with fromDate. The date and time is provided as seconds since the epoch.
fromCreationDate
Similar to fromDate, but fetches the events based on the creation date. The date and time is provided as seconds since the epoch.
toCreationDate
Search for events that have been created within a date range. This is to be used in combination with fromCreationDate. The date and time is provided as seconds since the epoch.
pageSize
Indicates how many entries of the collection are to be retrieved from Cumulocity IoT.
revert
Boolean parameter. By default, Cumulocity returns the latest events first. You can reverse the order by adding the query parameter revert=true. This returns the oldest event first.

Copyright © 2013-2019 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.