question

Upvotes
Accepted
76 2 1 11

EMA Config in Java

Hello,

I'm using the following EmaConfig.xml and all work fine and I want to switch to programmatic configuration. The ChannelSet section work fine (I see my channel names "Channel_1" and "Channel_2" in log) but it use localhost for each channel entries instead of "trep1" and "trep2". What is wrong?

Working EmaConfig.xml:

<?xml version="1.0" encoding="UTF-8"?>
<EmaConfig>
<ConsumerGroup>
<DefaultConsumer value="Consumer_1" />
<ConsumerList>
<Consumer>
<Name value="Consumer_1" />
<ChannelSet value="Channel_1,Channel_2" />
</Consumer>
</ConsumerList>
</ConsumerGroup>
<ChannelGroup>
<ChannelList>
<Channel>
<Name value="Channel_1" />
<Host value="trep1" />
<Port value="14002" />
</Channel>
<Channel>
<Name value="Channel_2" />
<Host value="trep1" />
<Port value="14002" />
</Channel>
</ChannelList>
</ChannelGroup>
</EmaConfig>


Non working Java code:

static Map createConfig() {
Map innerMap = EmaFactory.createMap();
Map configMap = EmaFactory.createMap();

ElementList elementList = EmaFactory.createElementList();
ElementList innerElementList = EmaFactory.createElementList();

elementList.add(EmaFactory.createElementEntry().ascii("DefaultConsumer", "Consumer_1"));

innerElementList.add(EmaFactory.createElementEntry().ascii("ChannelSet", "Channel_1,Channel_2"));

innerMap.add(EmaFactory.createMapEntry().keyAscii("Consumer_1", MapEntry.MapAction.ADD, innerElementList));
innerElementList.clear();

elementList.add(EmaFactory.createElementEntry().map("ConsumerList", innerMap));
innerMap.clear();

configMap.add(EmaFactory.createMapEntry().keyAscii("ConsumerGroup", MapEntry.MapAction.ADD, elementList));
elementList.clear();

innerElementList.add(EmaFactory.createElementEntry().ascii("Host", "trep1"));
innerElementList.add(EmaFactory.createElementEntry().ascii("Port", "14002"));
innerMap.add(EmaFactory.createMapEntry().keyAscii("Channel_1", MapEntry.MapAction.ADD, innerElementList));
innerElementList.clear();

innerElementList.add(EmaFactory.createElementEntry().ascii("Host", "trep2"));
innerElementList.add(EmaFactory.createElementEntry().ascii("Port", "14002"));
innerMap.add(EmaFactory.createMapEntry().keyAscii("Channel_2", MapEntry.MapAction.ADD, innerElementList));
innerElementList.clear();
elementList.add(EmaFactory.createElementEntry().map("ChannelList", innerMap));
innerMap.clear();
configMap.add(EmaFactory.createMapEntry().keyAscii("ChannelGroup", MapEntry.MapAction.ADD, elementList));
elementList.clear();
return configMap;
}


Thanks
Stephane

elektronrefinitiv-realtimeelektron-sdkrrtema-apielektron-message-apijava
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.

Upvotes
Accepted
11.5k 16 7 10

Hello @Stephane Rossi

Could you please add the following line before you set "Host" programmatically?

innerElementList.add(EmaFactory.createElementEntry().ascii( "ChannelType", "ChannelType::RSSL_SOCKET" ));

Example:

innerElementList.add(EmaFactory.createElementEntry().ascii( "ChannelType", "ChannelType::RSSL_SOCKET" ));
innerElementList.add(EmaFactory.createElementEntry().ascii("Host", "trep1"));
innerElementList.add(EmaFactory.createElementEntry().ascii("Port", "14002"));
innerMap.add(EmaFactory.createMapEntry().keyAscii("Channel_1", MapEntry.MapAction.ADD, innerElementList));
innerElementList.clear();

innerElementList.add(EmaFactory.createElementEntry().ascii( "ChannelType", "ChannelType::RSSL_SOCKET" ));
innerElementList.add(EmaFactory.createElementEntry().ascii("Host", "trep"));
innerElementList.add(EmaFactory.createElementEntry().ascii("Port", "14002"));
innerMap.add(EmaFactory.createMapEntry().keyAscii("Channel_2", MapEntry.MapAction.ADD, innerElementList));
innerElementList.clear();

Please see the full example in EMA Java ex421_MP_ProgrammaticCfg example.

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.

Upvotes
76 2 1 11

Thanks work fine, but why it is not needed when use the EmaConfig.xml?

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.

Upvotes
11.5k 16 7 10

Hello @Stephane Rossi

Based on the EMA Java Configuration guide, the default value of the ChannelType for the EmaConfig.xml file is "RSSL_SOCKET" value.

I suggest you set this ChannelType programmatically. In the meantime, I will check with the Developer team to confirm if the default value is applied to the programmatic configuration or not.


channeltype.png (37.9 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.

Upvotes
11.5k 16 7 10

Hello @Stephane Rossi

The file-based and programmatic configurations behavior difference issue has been fixed in EMA Java 3.6.3L1 (RTSDK 2.0.3). According to the RTSDK Change Log file, the programmatic configuration now sets the ChannelType "RSSL_SOCKET" as a default value.

You can download the RTSDK 2.0.3 from the RTSDK Java download link.

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.

Click below to post an Idea Post Idea