Apama 10.3.1 | Apama Capital Markets Foundation Documentation | Capital Markets Foundation | Market Data Management | Market data subscribers | Subscribing to market data | Subscription examples | Sample code for using subscriber object to subscribe
 
Sample code for using subscriber object to subscribe
After you obtain a subscriber object for a market data type, you can use that object to subscribe to receive market data. The following sample code shows this.
using com.apama.session.SessionHandlerFactory;
using com.apama.session.SessionHandler;
using com.apama.md.TradeSubscriberFactory;
using com.apama.md.TradeSubscriber;
 
monitor SubscriberExample2 {
 
context mainContext := context.current();
 
action onload() {
com.apama.session.SessionHandler sessionHandler :=
com.apama.session.SessionHandlerFactory.connect(
"MySession", "MyTransport");

// Obtain a trade subscriber and use it to subscribe
TradeSubscriber tradeSubscriber :=
TradeSubscriberFactory.create(sessionHandler);
tradeSubscriber.subscribe("EUR/USD");
}
 
// Process the trade
on all com.apama.md.T() {
...
}
}
Before you use a market data subscriber to subscribe you can execute actions on that subscriber to set parameters or add callbacks to be executed upon subscription, upon receiving market data, and upon unsubscribing. When you subscribe without specifying a callback, any callbacks you previously added are executed at the appropriate points. See Setting subscription callbacks.

Copyright © 2013-2019 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.