in you example code
try {
AppClient client;
OmmConsumer consumer(OmmConsumerConfig().host("my.ip.goes.here:14002").username("my_user_goes_here"));
consumer.registerClient(ReqMsg().serviceName("LDN_RSSL_DDS_CHE").name("MRN_STORY").domainType(MMT_NEWS_TEXT_ANALYTICS), client); // original
// Sleep long enough to receive a few stories
sleep( 60000 );// API calls onRefreshMsg(), onUpdateMsg() and onStatusMsg()
}
It uses a sleep() function to control how long it runs.
What if I do not want to use sleep(), but rather call something like
client.start() when my service (getting news from Elektron API) starts, and client.stop() when I want to stop the service (quitting ClientApp from memory).