Apama Capital Markets Foundation Documentation : Capital Markets Foundation : Utilities : Configuration Service : Configuration service initialization
Configuration service initialization
To start using the configuration service, an application must create and initialize a configuration store using the desired backing store implementation. For example, to create or load a configuration store backed by the on-disk Memory Store database in file myApp.db, see the following code. Access to the configuration database happens in parallel with the execution of application code in the Apama correlator, so races can easily occur if the application does not synchronize its activities with the service framework correctly.
When you use flat-file databases like myApp.db, you should be sure that they are backed up on a regular basis.
// CMF service framework
com.apama.service.framework.ServiceInterface frmwk;
// Abstract interface to the configuration service
com.apama.config.ConfigurationStoreInterface iface;
action onload() {
// Initialize the service framework
integer serviceId := frmwk.initialise("Sample", "ConfigServiceSample",
context.current(), allServicesInitialised );
// Called when the service framework has been initialised
action allServicesInitialised( integer serviceId ) {
// Initialize the Memory Store configuration service implementation
iface := (new com.apama.config.MemoryStoreConfigurationStore).getInterface
(constants.SERVICE_INSTANCE, constants.STORE_PATH);
iface.init(integer.getUnique(), onSuccess, onError);
// Called after store is initialized and all rows are loaded into memory
action onSuccess(integer id) {
log "Initialized configuration store" at INFO;
The getInterface() action returns a com.apama.config.ConfigurationStoreInterface object - an abstract interface to the store that can be used in the same way regardless of the backing store implementation. Calling the init() action on this object loads tables from the store and initializes the in-memory cache. Either the onSuccess() or onError() action will then be called.
The onSuccess() or onError() callback actions must be defined. If an application does not want to supply its own callbacks, the ConfigurationStoreInterface object provides default callback implementations. The default implementations route events that can be handled by an application-supplied listener.
If the store was successfully initialized, the application can query the available tables and their schemas, create new tables or get an interface to a named table. For example:
// 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;
// Assume the table already exists
com.apama.config.ConfigurationTableInterface _table
:= iface.getTable("TestTable");
// Iterate over all the rows of the table and log the value of a field
com.apama.memorystore.Iterator it := _table.begin();
while not it.done() {
com.apama.memorystore.Row row := it.getRow();
log row.getString("TestField") at INFO;
The Configuration Service includes a comprehensive sample (the Configuration Service Sample project in the ASB/samples directory of the CMF installation) that demonstrates how to use the features of the Configuration Service, including a simple dashboard and the use of the com.apama.config.ConfigurationRowHelper event to map individual table rows to event instances.
See the ApamaDoc for more details on the following:
Copyright © 2013-2017 Software AG, Darmstadt, Germany. (Innovation Release)

Product LogoContact Support   |   Community   |   Feedback