how to make EmaFactory to connect with the second host if the first host can not be connected

Hi, We are using the thomson-reuters-ema java api (version 3.5.1.0) to connect the EAM server. Recently we got a lot of errors like:


loggerMsg

ClientName: EmaConsumer_287

Severity: Error

Text: login failed (timed out after waiting 45000 milliseconds) for xxxxxxxx.europe.intranet:14002)

loggerMsgEnd


It turned out that a particular server was in maintenance. The others configured servers in hosts should be functioning. However, the EmaFactory is always trying to connect with the first host, and did not try the other hosts in the host list.


This log is generated by the EmaFactory, which cannot be modified by us. So the question is, how to let the EmaFactory only try once for the connection of each host? If it failed, then try another host? Currently it seems that the EmaFactory is always trying to connect with the first host in the host list.


Below is our code to connect to the EMA host, thanks.

--------------------------------------------------------------------

private OmmConsumer getOmmConsumer() {

OmmConsumer consumer;

for (String host : hosts) {

try {

LOGGER.debug("Start to connect with Trep Server: {} --- {}", host, user);

OmmConsumerConfig config = EmaFactory.createOmmConsumerConfig();

consumer = EmaFactory.createOmmConsumer(config.host(host).username(user).applicationId(APPLICATION_ID));

return consumer;

} catch (OmmException exception) {

LOGGER.warn(exception.getMessage());

}

}

return null;

}


Best Answer

  • @ning.kang

    OmmConsumerConfig.host(String) is to specify a hostname and port that EMA will connect to so it does not accept multiple hosts. You may need to use ChannelSet, as described in the following post instead.

Answers