Connecting to a quotebook datastream
Connecting to a quotebook datastream is similar to connecting to other built-in Apama datastreams. The process differs in the way you provide the information necessary to identify the exact quote you want the adapter to subscribe to connecting to the datasource. After you have found and started your session (see
Starting a session) and created a
MDManagerInterface object (see
Creating a market data manager) connect to a quotebook datastream as follows:
1. Using a MDManagerInterface object, call the hasQuotebook() action to see if the quotebook datastream is available.
2. If the quotebook datastream is available, create a QuotebookManager using the QuotebookInterfaceManager instance's createQuotebookManager() action. For example:
// this action is called if the creation of the MD manager was successful
action onCreationSuccess( com.apama.md.user.MDManagerInterface mdManager ) {
// Now create a new interface to the Quotebook Manager
if mdManager.hasQuotebook() then {
QuotebookManagerInterface quotebookManagerIface :=
mdManager.createQuotebookManager();
connect( quotebookManagerIface );
}
//...
}
3. Connect to the quotebook datastream using the QuotebookInterfaceManager instance's connect() action. For example:
// this action is called if the creation of the Quotebook manager was
// successful
action connect( QuotebookManagerInterface quotebookIface ) {
// Set the desired Connect Control Params
com.apama.session.CtrlParams connParams :=
new com.apama.session.CtrlParams;
connParams.addParam("Currency", "USD");
// Connect to a Quotebook Manager for a given symbol
quotebookIface.connect(symbol,
connParams,
onConnectionSuccess,
onFailureToConnect);
//. . .
}
The second argument to the
connect() action contains the various Control Parameters that indicates the quote you want to connect to in the quotebook. For more information on how to specify the Control Parameters, see
Specifying control parameters