Apama 10.7.2 | Connecting Apama Applications to External Components | Standard Connectivity Plug-ins | The Cumulocity IoT Transport Connectivity Plug-in | Using operations | Querying for operations
 
Querying for operations
To search for an operation or a collection of operations, send the com.apama.cumulocity.FindOperation event to Cumulocity IoT, with a unique reqId to the com.apama.cumulocity.FindOperation.SEND_CHANNEL channel.
The transport will then respond with zero or more com.apama.cumulocity.FindOperationResponse events and then one com.apama.cumulocity.FindOperationResponseAck event on the com.apama.cumulocity.FindOperationResponse.SUBSCRIBE_CHANNEL channel.
Example:
integer reqId := com.apama.cumulocity.Util.generateReqId();
 
com.apama.cumulocity.FindOperation request :=
new com.apama.cumulocity.FindOperation;
request.reqId := reqId;
 
// Filter based on operation status
request.params.add("status", "PENDING");

 
// Subscribe to com.apama.cumulocity.FindOperationResponse.SUBSCRIBE_CHANNEL
// to listen for responses
monitor.subscribe(com.apama.cumulocity.FindOperationResponse.SUBSCRIBE_CHANNEL);
 
// Listen for responses based on reqId
on all com.apama.cumulocity.FindOperationResponse(reqId=reqId) as response
// Avoid listener leaks by terminating the listener on completion of the request
and not com.apama.cumulocity.FindOperationResponseAck(reqId=reqId)
{
log "Received Operation " + response.toString() at INFO;
}
 
// Listen for com.apama.cumulocity.FindOperationResponseAck,
// this indicates that all responses have been received
on com.apama.cumulocity.FindOperationResponseAck(reqId=reqId)
as requestCompleted
{
log "Received all Operation(s) for request "
+ requestCompleted.reqId.toString() at INFO;
 
// Request is completed and we can unsubscribe from this channel
monitor.unsubscribe(com.apama.cumulocity.FindOperationResponse.SUBSCRIBE_CHANNEL);
}
 
// Send request to find available operations
send request to com.apama.cumulocity.FindOperation.SEND_CHANNEL;
Supported query parameters
You can provide the following query parameters with the request:
Parameter
Description
id
Search for an operation based on operationId. When searching for an operation based on Id, all the query parameters listed below are ignored.
source
Search for operations based on the device identifier or asset identifier of the source.
status
Search for operations based on the status. The status can be any of SUCCESSFUL, FAILED, EXECUTING or PENDING.
agent
Search for operations based on the agent identifier.
fragmentType
Search for operations based on the fragment type.
pageSize
Indicates how many entries of the collection are to be retrieved from Cumulocity IoT. This is a batching parameter for getting multiple responses from Cumulocity IoT. A larger pageSize does fewer requests to Cumulocity IoT to retrieve all the operations, but each request is larger. By default, 1000 operations are in each page and there is an upper limit of 2000.
currentPage
Retrieve a specific page of results for the given pageSize. If currentPage is set, then only a single page is requested. If currentPage is not set (default), all the pages are requested.
fromDate
Search for operations from a start date. The date and time is provided as seconds since the epoch.
toDate
Search for operations within a time range. This is to be used in combination with fromDate. The date and time is provided as seconds since the epoch.
Query result paging
Cumulocity IoT queries support paging of data for requesting a specific range of the responses received. For more information, see Paging Cumulocity IoT queries.