question

Upvotes
Accepted
25 2 5 9

Multiple hostnames in consumerConfig for EMA ?

OmmConsumerConfig config = EmaFactory.createOmmConsumerConfig(); consumer = EmaFactory.createOmmConsumer(config.host(getHostName() + ":" + getPortNumber()).username(getUserName()));

Is there an option to provide multiple hostnames to the createOmmConsumer(config.host()) for load balancing or fail-safe operation? Can you please provide with any example if its possible?

elektronrefinitiv-realtimeelektron-sdkrrtema-apielektron-message-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

1 Answer

Upvotes
Accepted
9.5k 10 5 7

Hello @sagar.s

OmmConsumerConfig.host(String) is to specify a hostname and port that EMA will connect to so it does not accept multiple hosts. However, EMA provides another way to configure EMA for multiple hosts by using ChannelSet parameter in the Configuration file named EmaConfig.xml as explained in EMAJ_ConfigGuide.pdf:

The example of ChannelSet for multiple Channels in EmaConfig.xml:

<Consumer>
    <Name value="Consumer_2"/>
    <!-- ChannelSet specifies an ordered list of Channels to which OmmConsumer will attempt to    -->
    <!-- connect, one at a time, if the previous one fails to connect                            -->
    <ChannelSet value="Channel_1, Channel_2"/>
    <Dictionary value="Dictionary_2"/>
    <XmlTraceToStdout value="0"/>
</Consumer>

Each Channel can specify a host and port:

<Channel>
    <Name value="Channel_1"/>
    ...
    <Host value="localhost"/>
    <Port value="14002"/>
</Channel>
<Channel>
    <Name value="Channel_2"/>
    ...
    <Host value="192.168.27.48"/>
    <Port value="14002"/>
</Channel>

You can try example110__MarketPrice__FileConfig which loads Consumer_2 configuration that sets multiple Channels in the ChannelSet parameters. The application loads Consumer_2 from EmaConfig.xml file located in the application's working directory.

The snipped source code to load Consumer_2 configuration:

consumer  = EmaFactory.createOmmConsumer(EmaFactory.createOmmConsumerConfig().consumerName("Consumer_2"));

The example output when EMA tried to connect to the first host in Channel_1 but it failed. Then, it tried to connect to the second host in Channel_2 and it succeeded:


channelset.png (16.3 KiB)
ema-log.png (23.1 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

It works for me: after trying several channel, it finds the good one. But then, when I try to register with another service name that depends on another channel, it doesn't work. It seems my consumer doesn't retry all channel and keeps the previous one.
Do you know if there is a way to force it to change its channel each time it is called?

Hello @TD_BNP

I do not know the way to do this. Please contact EMA development team who is the product expert and should be able to help you on this. You can contact the development team directly via https://github.com/thomsonreuters/Elektron-SDK/issues then click "New issue" button.

Click below to post an Idea Post Idea