Service Framework
The Service Framework allows applications to ensure that all services they use, such as the Risk Firewall and the Position Service, are fully configured before the rest of the application is allowed to start. Configuration may entail loading a persisted set of configuration data from an external source, such as loading persisted Risk Firewall rule instances from a database.
Without the Service Framework, the application would have to arbitrarily assume when the application is fully configured, or listen for a complex set of events indicating that configuration is complete. Such events might include those ensuring that the Risk Firewall has loaded its rule instance, the Position Service has been enabled, and the Market Data Architecture has been made available to send market data through the system.
To support multi-context environments, the Service Framework includes two parts:
Service Framework Manager
The Service Framework Manager monitors the status of all Service Interfaces that are created in the application, and the context they are created within. It also responsible for communicating with all instances of the Service Interfaces when the application activates the Service Framework. The application should not communicate directly with the Service Framework Manager other than to send the Activate() event to the context it resides in. All other communication with it should be through the Service Interface described below.
Service Interface
The Service Interface event object (com.apama.service.framework.ServiceInterface) should be created by any application EPL monitor instances that:
require the two-stage startup process to ensure that the service is initialized/configured before the rest of the application is allowed to continue
depend on another service being fully configured (such as relying on the Risk Firewall being available)
To use the Service Framework in an application, inject the Service Framework bundle into the correlator. This ensures that the appropriate EPL code (including any dependencies) is injected in the appropriate order.
The CMF Service framework employs a two-stage startup. The first phase creates and configures any necessary services. The application should activate the second phase by sending a com.apama.config.Activate() event after all EPL code has been injected and any external adapters have been started. This effectively informs all users of those services that they are ready. This ensures that the second stage does not start until all services created by the application have been setup and configured.