com.apama.cumulocity
Event AutoConcurrentConnection


A connection to Cumulocity IoT which is configured to handle most requests concurrently to improve performance.

Requests are handled concurrently unless this could result in getting and setting occurring in the wrong order. The semantics for which requests are executed concurrently is the same as for the standard client. Details can be found in the Optimizing requests to Cumulocity IoT with concurrent connections section of the documentation.

For example:
        
// Starting a connection with 4 clients
AutoConcurrentConnection connection := AutoConcurrentConnection.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
// AutoConcurrentConnection connection := AutoConcurrentConnection.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);
See Also:
com.apama.cumulocity.TenantSubscriptionNotifier - to retrieve the TenantDetails object for a given tenant.
com.apama.cumulocity.FullyConcurrentConnection - to create a connection configured to handle all requests concurrently.
com.apama.cumulocity.SerialConnection - to create a connection configured to handle all requests using a single client.
com.apama.cumulocity.SharedConnection - to reuse the global connection instance.

Action summary
 com.apama.cumulocity.AutoConcurrentConnectionstatic create(integer numClients)

Returns a new AutoConcurrentConnection.
 com.apama.cumulocity.AutoConcurrentConnectionstatic createForTenant(com.apama.cumulocity.TenantDetails tenant, integer numClients)

Returns a new AutoConcurrentConnection.
 voiddestroy()

Destroys this connection to Cumulocity IoT.
 stringgetChannel(string channel)

Returns the channel to which events should be sent for concurrent processing.
 
Action detail

create

            com.apama.cumulocity.AutoConcurrentConnection static create(integer numClients)
        
Returns a new AutoConcurrentConnection.

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 AutoConcurrentConnection.
See Also:
com.apama.cumulocity.AutoConcurrentConnection#createForTenant() - to create a connection when the application also needs to work with multi-tenant deployment.

createForTenant

            com.apama.cumulocity.AutoConcurrentConnection static createForTenant(com.apama.cumulocity.TenantDetails tenant, integer numClients)
        
Returns a new AutoConcurrentConnection.
Parameters:
tenant - Tenant details.
numClients - The number of simultaneous threads and HTTP client connections to use for requests.
Returns:
The new AutoConcurrentConnection.

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.