in you example code
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).
Have you looked at example 130__MarketPrice__UserDisp which illustrates User Dispatching as opposed to API dispatch mechanism.
Please refer to section 2.4.1 EMA Consumer Architecture of the EMA Developers guide for more information on dispatching.