Apama Capital Markets Foundation Documentation : Capital Markets Foundation : Market Data Management : Using low-level MDA interfaces : Accessing datastream information
Accessing datastream information
The sample in this section shows how to access the datastream information assuming the connection has been successful. The example shows two methods of accessing the data, one uses an update callback that is registered with the manager object and triggers when any new data is available. These update handlers can be added and removed at will and as many times as required, as shown in the sample.
It is worth noting that in the case of snapshot event-only data, events that include all the information about the current state of the market, such as best-bid-ask (BBA) or trade data, using listeners would seem very reasonable. However, large data structures such as the orderbook and depth events are usually not sent as whole snapshot events for obvious efficiency reasons. Therefore, the manager access functions are generally the best way to obtain the most recent data. These functions collate and cache the data and provide them to the user.
// this action is called if the creation of the BBA manager was successful
action onConnectionSuccess(com.apama.md.adapter.ConnectionKey connKey) {
log "connected BBA for: "+ connKey.getSymbol();
// 1. Demonstrating call back setup procedure
// Add an update callback for all BBA if we were successful
integer updateRef := bbaManagerIface.addUpdateCallback( connKey, onAllBba);
// 2. Demonstrating access to datastream via listener
com.apama.md.BBA bbaInst;
on all com.apama.md.BBA(symbol=connKey.getSymbol()):bbaInst {
// Wait a while then disconnect
on wait(30.0) {
boolean success := bbaManagerIface.removeCallback(
updateRef );
The following actions are used in the code above to handle the BBA data. Note the difference in the input argument of the two actions.
// This callback is called whenever we get a new BBA using the callback
// mechanism
action onAllBba( com.apama.md.client.CurrentBBAInterface currBba ) {
log "Got BBA using Callback- " at INFO;
log " for symbol: " + symbol at INFO;
log " Bid Quantity: " + currBba.getBidQty().toString() at INFO;
log " Bid Price: " + currBba.getBidPrice().toString() at INFO;
log " Ask Quantity: " + currBba.getAskQty().toString() at INFO;
log " Ask Price: " + currBba.getAskPrice().toString() at INFO;
log " With EP: " + currBba.getEPValuesInterface().getRaw().toString() at INFO;
// This callback is called whenever we get a new BBA using listeners
action handleBba( com.apama.md.Bba currBba ) {
log "Got BBA using Listener - " at INFO;
log " for symbol: " + symbol at INFO;
log " Bid Quantity: " + currBba.bidQuantity.toString() at INFO;
log " Bid Price: " + currBba.bidPrice.toString() at INFO;
log " Ask Quantity: " + currBba.askQuantity.toString() at INFO;
log " Ask Price: " + currBba.askPrice.toString() at INFO;
The following shows an example of how to select the datastream transfer mode.
// Modes for connecting to an Orderbook datastream
com.apama.session.CtrlParams conParams := new com.apama.session.CtrlParams;

// Snapshot mode:

// Atomic Delta mode:

// Compound Delta mode:

orderbokManagerIface.connect(symbol, conParams, onSuccess, OnFailure);
Copyright © 2013-2017 Software AG, Darmstadt, Germany. (Innovation Release)

Product LogoContact Support   |   Community   |   Feedback