Capital Markets Adapters 10.3 | Apama Capital Markets Adapters Documentation 10.3 | Reuters RFA Adapter | Working with Machine Readable News | Integrating RFA with MDA
 
Integrating RFA with MDA
The Market Data Architecture can be used together with RFA adapter that use legacy components. The Capital Markets Foundation includes a Market Data Bridge service that allows you to implement applications with all the benefits of the Market Data Architecture and still use an adapter that uses legacy interfaces. After the Market Data Bridge has been created, the service handles all the connection/communication protocol for both session management and datastream management. The legacy adapter appears as an Market Data Architecture session.
*To integrate RFA with Market Data Architecture
1. Start RFA adapter by sending session configuration event where application type is OMMMRN.
2. Send RFA login and ensure that it is successful.
3. Send subscription requests to RFA using Market Data Bridge. In the following EPL, the connect request for RIC MRN_STORY is transformed to RFA subscribe tick request.

package com.apama.news.test;

using com.apama.session.SessionHandler;
using com.apama.session.SessionHandlerFactory;

using com.apama.md.NewsSubscriberFactory;
using com.apama.md.NewsSubscriber;

using com.apama.md.client.CurrentNewsInterface;

using com.apama.md.DatastreamConstants;
using com.apama.md.bridge.BridgeConstants;

using com.apama.md.bridge.ConfigMDBridge;
using com.apama.md.bridge.MDBridgeInterface;
using com.apama.md.bridge.MDBridgeExtensionFactory;
using com.apama.md.bridge.MDBridgeExtensionInterface;
using com.apama.md.bridge.NewsHelper;

using com.apama.md.adapter.ConnectDatastream;
using com.apama.md.adapter.DisconnectDatastream;

using com.apama.marketdata.SubscribeTick;
using com.apama.marketdata.UnsubscribeTick;
using com.apama.marketdata.Tick;

event RFA_News_Subscription_Helper {

ConfigMDBridge bridgeConfig;
MDBridgeExtensionInterface bridgeExtension;

action init(string serviceId, string marketId) {

// Setup the Bridge configuration
bridgeConfig.serviceId := serviceId;
bridgeConfig.marketId := marketId;
bridgeConfig.streamTypes := [DatastreamConstants.DATASTREAMTYPE_NEWS];
bridgeConfig.extraConfig := {BridgeConstants.CONST_DISABLE_STATUS_SUPPORT:"true"};

//Add our Bridge extension
bridgeExtension := (new MDBridgeExtensionFactory).createInterface();
bridgeExtension.subscribeOthers := subscribeOthers;
bridgeExtension.unsubscribeOthers := unsubscribeOthers;
}

action getMDBridgeConfig() returns ConfigMDBridge { return bridgeConfig; }
action getMDBridgeExtensionInterface()
returns MDBridgeExtensionInterface { return bridgeExtension; }

action subscribeOthers(string serviceId, string marketId,
ConnectDatastream cds) returns boolean {

log "Bridge extension for Others subscription for Service Id : "
+ serviceId + " Market Id : "+ marketId + " symbol : "+ cds.symbol at INFO;

SubscribeTick subTick := new SubscribeTick;
subTick.symbol := cds.symbol;
subTick.serviceId := serviceId;
subTick.marketId := marketId;
route subTick;

NewsHelper newsHelper := new NewsHelper;
newsHelper.setConnectionId(cds.clientId + 1);
newsHelper.setSessionId(cds.sessionId);
newsHelper.setSymbol(cds.symbol);

Tick tick;
on all Tick(symbol=cds.symbol):tick
and not UnsubscribeTick(serviceId=serviceId, marketId=marketId, symbol=cds.symbol)
{

if (tick.extraParams.hasKey("body")) then {
newsHelper.setStory(tick.extraParams["body"]);
tick.extraParams.remove("body");
}

if (tick.extraParams.hasKey("headline")) then {
newsHelper.setHeadline(tick.extraParams["headline"]);
tick.extraParams.remove("headline");
}

if (tick.extraParams.hasKey("GUID")) then {
newsHelper.setNewsId(tick.extraParams["GUID"]);
tick.extraParams.remove("GUID");
}

newsHelper.setUpdateType(0);
newsHelper.setData(tick.extraParams);

boolean success := newsHelper.publishN();
}
return true;
}

action unsubscribeOthers(string serviceId, string marketId,
DisconnectDatastream dcds) returns boolean {

log "Bridge extension for Others unsubscription for Service Id : "
+ serviceId + " Market Id : "+ marketId + " symbol : "+ dcds.symbol at INFO;

UnsubscribeTick unsubTick := new UnsubscribeTick;
unsubTick.symbol := dcds.symbol;
unsubTick.serviceId := serviceId;
unsubTick.marketId := marketId;
route unsubTick;

return true;
}
}

monitor News_Subscription_Tester {

context mainContext := context.current();

constant string REUTERS_RFA_SERVICE_ID := "DIRECT_FEED";
constant string REUTERS_RFA_TRANSPORT_NAME := "ReutersRFATransport";

action onload() {

RFA_News_Subscription_Helper rfaHelper := new RFA_News_Subscription_Helper;
rfaHelper.init(REUTERS_RFA_SERVICE_ID, REUTERS_RFA_TRANSPORT_NAME);

(new MDBridgeInterface).createMDBridge( mainContext,
rfaHelper.getMDBridgeConfig(),
rfaHelper.getMDBridgeExtensionInterface()
);

//start Session
SessionHandler sessionHandler := (new SessionHandlerFactory).connect(
mainContext,
rfaHelper.getMDBridgeConfig().getSessionName(),
BridgeConstants.CONST_TRANSPORT_NAME
);

NewsSubscriber newsSubscriber := (new NewsSubscriberFactory).create(sessionHandler);
integer retVal := newsSubscriber.addSubscribedCallback(onNewsSubscribed);

newsSubscriber.subscribeCb("N2_STORY", onNewsUpdate);

}

action onNewsSubscribed(NewsSubscriber handler,
com.apama.md.adapter.ConnectionKey connKey) {

log "Successfully subscribed for symbol: " + connKey.getSymbol() at INFO ;

}

action onNewsUpdate(CurrentNewsInterface newsIface) {
log "Got News for " + newsIface.getSymbol() + "\n News ID : " + newsIface.getNewsId()
+ "\n Headline : " + newsIface.getHeadline()
+ "\n Story : " + newsIface.getStory() at INFO;
}
}
After the subscription is successful, NEWS events appear:

News ID : b601d90010161028
Headline : Changes In Boardroom Announcement -
Change in Boardroom(AXIATA GROUP BHD)<AXIA.KL>
Story : Company Name : AXIATA GROUP BHD
Stock Code : 6888 (RIC : AXIA.KL)
Change in Boardroom
Name : BELLA ANN ALMEIDA
Designation : DI
Status : RS
Date of Appointment : 2017/05/25
Directorate : Ind & N/Exec
Age : 60
Country :
Nationality : United Kingdom
Working Experience : You are advised to read the entire
contents of the announcement or attachment. To read the
entire contents of the announcement or attachment,

access the Bursa website at http://www.bursamalaysia.com
Other Directorship :
Remarks : Resigned as Member of Board Nomination Committee
and Board Remuneration

Committee with effect from the date hereof.

You are advised to read the entire contents of the announcement or attachment.
To read the entire contents of the announcement or attachment, access
the Bursa website at http://www.bursamalaysia.com
Qualifications : MA in Economics, Cambridge University, UKMBA,
Imperial College, London, UK
Description : Nil
Interest In the securities : Nil
Composition Of Audit Committee :