How to specify multiple hosts while connecting using ETA reactor api?
I am using reactor api for consuming data from reuters feed. How to specify multiple hosts in connection config?
I am using below code:
connectOptions.connectionList().add(connectInfo);
connectOptions.connectionList().get(0).connectOptions().majorVersion(Codec.majorVersion());
connectOptions.connectionList().get(0).connectOptions().minorVersion(Codec.minorVersion());
connectOptions.connectionList().get(0).connectOptions().connectionType(ConnectionTypes.SOCKET);
connectOptions.connectionList().get(0).connectOptions().unifiedNetworkInfo().address(srvrHostname);
connectOptions.connectionList().get(0).connectOptions().unifiedNetworkInfo().serviceName(srvrPortNo);
connectOptions.connectionList().get(0).connectOptions().guaranteedOutputBuffers(1000);
// Prepare our connection
//connectOptions.connectionList().add(connectInfo);
connectOptions.connectionList().get(1).connectOptions().majorVersion(Codec.majorVersion());
connectOptions.connectionList().get(1).connectOptions().minorVersion(Codec.minorVersion());
connectOptions.connectionList().get(1).connectOptions().connectionType(ConnectionTypes.SOCKET);
connectOptions.connectionList().get(1).connectOptions().unifiedNetworkInfo().address(srvrHostname2);
connectOptions.connectionList().get(1).connectOptions().unifiedNetworkInfo().serviceName(srvrPortNo);
connectOptions.connectionList().get(1).connectOptions().guaranteedOutputBuffers(1000);
After hit trial, I noticed that by uncommenting the code, I can make connection.
However, when I print host name in channel_Up or channel_ready events, It is always 2nd host i.e.
connectOptions.connectionList().get(1).connectOptions().unifiedNetworkInfo().address(srvrHostname2);
1) Is above correct way to connect using multiple hosts ?
2) I am using reconnect tries as -1, so how reactor api will be failed over to other host in pipeline?
Best Answer
-
You can refer to the VAConsumer example code. It demonstrates how to add a backup server.
if (consumerCmdLineParser.backupHostname() != null && consumerCmdLineParser.backupPort() != null)
{
ReactorConnectInfo connectInfo = ReactorFactory.createReactorConnectInfo();
chnlInfo.connectOptions.connectionList().add(connectInfo);
chnlInfo.connectOptions.connectionList().get(1).connectOptions().majorVersion(Codec.majorVersion());
chnlInfo.connectOptions.connectionList().get(1).connectOptions().minorVersion(Codec.minorVersion());
chnlInfo.connectOptions.connectionList().get(1).connectOptions().connectionType(chnlInfo.connectionArg.connectionType());
chnlInfo.connectOptions.connectionList().get(1).connectOptions().unifiedNetworkInfo().serviceName(consumerCmdLineParser.backupPort());
chnlInfo.connectOptions.connectionList().get(1).connectOptions().unifiedNetworkInfo().address(consumerCmdLineParser.backupHostname());
chnlInfo.connectOptions.connectionList().get(1).connectOptions().userSpecObject(chnlInfo);
chnlInfo.connectOptions.connectionList().get(1).connectOptions().guaranteedOutputBuffers(1000);It creates a new instance of ReactorConnectInfo and then adds it to the connection list.
Please let me know which line causes the index out-of-bounds exception.
0
Answers
-
@Jirapongse please see below comment0
-
If i uncomment this line , then i wont get Index out of bound exception
- //connectOptions.connectionList().add(connectInfo);
IF there are two hosts, then we need below line twice :
connectOptions.connectionList().add(connectInfo);
I have fixed the code to below, however I still dont see in logs connection being made to back up host, Could you please assist here ?
private ReactorConnectInfo backUpConnectInfo = ReactorFactory.createReactorConnectInfo();
private ReactorDispatchOptions dispatchOptions = ReactorFactory.createReactorDispatchOptions();
// Prepare our connection
connectOptions.connectionList().add(connectInfo);
connectOptions.connectionList().get(0).connectOptions().majorVersion(Codec.majorVersion());
connectOptions.connectionList().get(0).connectOptions().minorVersion(Codec.minorVersion());
connectOptions.connectionList().get(0).connectOptions().connectionType(ConnectionTypes.SOCKET);
connectOptions.connectionList().get(0).connectOptions().unifiedNetworkInfo().address(srvrHostname);
connectOptions.connectionList().get(0).connectOptions().unifiedNetworkInfo().serviceName(srvrPortNo);
connectOptions.connectionList().get(0).connectOptions().guaranteedOutputBuffers(1000);
// Prepare our back up connection
connectOptions.connectionList().add(backUpConnectInfo);
connectOptions.connectionList().get(1).connectOptions().majorVersion(Codec.majorVersion());
connectOptions.connectionList().get(1).connectOptions().minorVersion(Codec.minorVersion());
connectOptions.connectionList().get(1).connectOptions().connectionType(ConnectionTypes.SOCKET);
connectOptions.connectionList().get(1).connectOptions().unifiedNetworkInfo().address(srvrHostname2);
connectOptions.connectionList().get(1).connectOptions().unifiedNetworkInfo().serviceName(srvrPortNo);
connectOptions.connectionList().get(1).connectOptions().guaranteedOutputBuffers(1000);
connectOptions.reconnectAttemptLimit(-1); // attempt to recover forever
connectOptions.reconnectMinDelay(1000); // 1 second minimum
connectOptions.reconnectMaxDelay(60000); // 60 second
maximu0 -
You can specify many ReactorConnectInfo in the connection list but ETA will connect to one server at a time. For example, if you have two servers in the list, ETA will establish a connection to the first server. It will failover to the second server if it can detect disconnection from the first server.
0
Categories
- All Categories
- 6 AHS
- 39 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛