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

Best Answer

  • wasin.w
    wasin.w admin
    Answer ✓

    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.

Answers

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

  • 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.

    image

    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.

  • 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.