com.apama.cumulocity
Event FullyConcurrentConnection
A connection to Cumulocity IoT which is configured to handle all requests concurrently to improve performance.
For example: // Starting a connection with 4 clients
FullyConcurrentConnection connection := FullyConcurrentConnection.create(4);
// Or alternatively for multi-tenant deployments, use a tenant-specific connection object
// Uses a TenantDetails object as input parameter. TenantDetails can be retrieved using TenantSubscriptionNotifier or ApplicationSubscribedForTenant
// FullyConcurrentConnection connection := FullyConcurrentConnection.createForTenant(tenantDetails, 4);
// Subscribing to a response channel
monitor.subscribe(connection.getChannel(FindManagedObjectResponse.SUBSCRIBE_CHANNEL));
// Requesting via a send channel
FindManagedObject findManagedObject := new FindManagedObject;
findManagedObject.reqId := Util.generateReqId();
send findManagedObject to connection.getChannel(FindManagedObject.SEND_CHANNEL);
Note that requests may be processed out of order when using this connection. To ensure that updates for each managed object are processed in order, use an AutoConcurrentConnection instead.- See Also:
- com.apama.cumulocity.TenantSubscriptionNotifier - to retrieve the TenantDetails object for a given tenant.
- com.apama.cumulocity.SerialConnection - to create a connection configured to handle all requests using a single client.
- com.apama.cumulocity.AutoConcurrentConnection - to create a connection configured to handle requests concurrently unless this could result in getting and setting occurring in the wrong order.
- com.apama.cumulocity.SharedConnection - to reuse the global connection instance.
create
com.apama.cumulocity.FullyConcurrentConnection static create(integer numClients)
Returns a new FullyConcurrentConnection.
This action must only be used when the application needs to work only with the per-tenant deployment. Use the createForTenant action when the application also needs to work with the multi-tenant deployment.- Parameters:
- numClients - The number of simultaneous threads and HTTP client connections to use for requests.
- Returns:
- The new FullyConcurrentConnection.
- See Also:
- com.apama.cumulocity.FullyConcurrentConnection.createForTenant() - to create a connection when the application also needs to work with multi-tenant deployment.
createForTenant
com.apama.cumulocity.FullyConcurrentConnection static createForTenant(com.apama.cumulocity.TenantDetails tenant, integer numClients)
Returns a new FullyConcurrentConnection.- Parameters:
- tenant - Tenant details.
- numClients - The number of simultaneous threads and HTTP client connections to use for requests.
- Returns:
- The new FullyConcurrentConnection.
destroy
void destroy()
Destroys this connection to Cumulocity IoT.
You should invoke this action on every connection after you have finished using it. Invoking this action on a connection that has already been destroyed does nothing. For example: action ondie() {
connection.destroy();
}
getChannel
string getChannel(string channel)
Returns the channel to which events should be sent for concurrent processing.- Parameters:
- channel - The corresponding standard Cumulocity IoT channel for single-threaded processing.
- Returns:
- The channel to which events should be sent of concurrent processing.