com.apama.cumulocity
Event SharedConnection


A connection to Cumulocity IoT which is configured to handle all requests using a shared client.

It is most useful for applications in multi-tenant deployment to get tenant-specific channels using the default per-tenant connections.

For example:

// Starting a connection
SharedConnection connection := SharedConnection.create();

// 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
// SharedConnection connection := SharedConnection.createForTenant(tenantDetails);

// 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.AutoConcurrentConnection - to create a connection configured to handle requests concurrently unless this could result in getting and setting occurring in the wrong order.

Action summary
 com.apama.cumulocity.SharedConnectionstatic create()

Returns a new SharedConnection.
 com.apama.cumulocity.SharedConnectionstatic createForTenant(com.apama.cumulocity.TenantDetails tenant)

Returns a new SharedConnection for a specific tenant.
 voiddestroy()

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

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

create

com.apama.cumulocity.SharedConnection static create()
Returns a new SharedConnection.

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

createForTenant

com.apama.cumulocity.SharedConnection static createForTenant(com.apama.cumulocity.TenantDetails tenant)
Returns a new SharedConnection for a specific tenant.
Parameters:
tenant
Returns:
The new SharedConnection.

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 processing.
Parameters:
channel - The corresponding standard Cumulocity IoT channel.
Returns:
The channel to which events should be sent for processing.