Price spreader example
Once the source has been created, call the startSession() action to get the underlying MDManagerInterface which can then be used to query and create specific datastream managers.
action startSession(com.apama.session.SessionStart sStr,
action<integer> onSuccess,
action<integer,string> onFailure) {
sessionStarted := true;
com.apama.md.user.MDManagerInterface underlyingMDManager :=
sourceHelper.getUnderlyingMDMangerForSessionId(
underlyingSession.getSessionId());
}
You can query the MDManagerInterface for the availability of required datastreams and if available, use the relevant datastream manager to access that specific datastream. The following is a list of the available actions for the built-in datastream types relevant to the Price Spreader:
hasA(),
createAggregatedBookManager() hasDepth(),
createDepthManager() hasBBA(),
createBBAManager() For example, to access the BBA datastream, the following code would be required in order to obtain the relevant manager.
if underlyingMDManager.hasBBA() then {
underlyingBBAIFace := underlyingMDManager.createBBAManager();
underlyingStreamType := localConsts.BBA();
}
After the relevant datastream managers have been created, the connect() action is called to connect to them.
action connect(
ConnectDatastream cds,
string underlyingSymbolName,
action<com.apama.md.adapter.ConnectionKey, integer> onConnectSuccess,
action<com.apama.md.adapter.ConnectionKey, integer, string> onConnectFailure)
Depending on what the stream type is, a connection to the datastream manager is established. For example, to check for stream type depth and connect to the depth manager:
if underlyingStreamType = localConsts.DEPTH()
then {
underlyingDepthIFace.connect( underlyingSymbolName,
underlyingConnectionParams, handleUnderlyingSessionError,
onUnderlyingConSuccess, onUnderlyingConFailure );
}
After the successful connection to the underlying datastream manager call the createConnection() action to setup callback references and register connection.
action createConnection( com.apama.md.adapter.ConnectDatastream cds,
com.apama.md.adapter.ConnectionKey underlyingConnKey )