Apama 10.3 | Apama Capital Markets Foundation Documentation | Capital Markets Foundation | Utilities | Configuration Service | Creating a configuration store
 
Creating a configuration store
To create a new table in a successfully initialized configuration store, the application must specify the schema for the table. The configuration service uses the standard Apama MemoryStore schema type to specify the field names and types for the table, but also allows the application to specify the set of fields that will be used to construct the keys for each row of the table. The key field(s) for a row form a key that is unique within the table.
The following example shows how to create a table. Note that instead of assuming the table does not exist, the code should first check and then create the table only if it does not exist:
// Called when the store has been initialized and all
//persisted rows have been loaded into memory
action onSuccess(integer id) {
log "Initialized configuration store" at INFO;
 
// If the table already exists, jump directly to the next step
if iface.hasTable(constants.TABLE_NAME) then {
log "Sample table already exists" at INFO;
onSuccess2(integer.getUnique(), iface.getTable("TestTable"));
}
 
// Otherwise, create the sample table
else {
com.apama.memorystore.Schema mSchema := new com.apama.memorystore.Schema;
mSchema.fields := ["stringField", "integerField"];
mSchema.types := ["string", "integer"];
 
com.apama.config.Schema schema := new com.apama.config.Schema;
schema.tableName := "TestTable";
schema.schema := mSchema;
schema.indexFields := ["stringField"];
schema.extraParams := {};
log "Creating sample table..." at INFO;
iface.createTable(integer.getUnique(), schema, onSuccess2, onError);
}
}
 
// Called when the sample table has been created or retrieved
action onSuccess2(
integer id, com.apama.config.ConfigurationTableInterface _table) {
 
log "TestTable created or retrieved successfully" at INFO;
}

Copyright © 2013-2018 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.