Session sharing with Application Engine

You can use the OLAPAttachConnection function to create a new OLAP connection with an existing session ID from Application Studio.

The function allows to reuse the existing session members but also to optimize performance. This example demonstrates how to use the function:

#define EngineVersion 5.0
#define RuntimeVersion 5.0

string OlapAttachConnectionProcess(string databaseName, string sid)
@Description: "Sample process using OLAPAttachConnection function";
@Category: "Sample processes";
@Returns: "Semicolon separated list of cube names";
@Parameter[databaseName]: "Database name";
@Parameter[sid]: "Session id";
{
	// Attach.
	OLAPConnection connection = OLAPAttachConnection(databaseName, sid);
	
	// Use the connection. 
	string cubeNames = "";
	foreach(OLAPCube cube in OLAPGetCubeList(connection))
	{
		cubeNames = cubeNames + OLAPGetCubeName(cube) + ";";
	}

	// Disconnect.
	OLAPDisconnect(connection);

	return cubeNames;
}

In Application Studio, the session ID can be obtained by the function GETSESSIONID("alias"). If you call the process from a defined action in Application Studio, the session ID can be passed to Application Engine and can then be used to create an OLAP connection or an XMLA connection.