///*|---------------------------------------------------------------------------------------------------- // *| This source code is provided under the Apache 2.0 license -- // *| and is provided AS IS with no warranty or guarantee of fit for purpose. -- // *| See the project's LICENSE.md for details. -- // *| Copyright Thomson Reuters 2016. All rights reserved. -- ///*|---------------------------------------------------------------------------------------------------- package com.thomsonreuters.ema.examples.training.consumer.series100.example100__MarketPrice__Streaming; import com.thomsonreuters.ema.access.Msg; import com.thomsonreuters.ema.access.AckMsg; import com.thomsonreuters.ema.access.GenericMsg; import com.thomsonreuters.ema.access.RefreshMsg; import com.thomsonreuters.ema.access.ReqMsg; import com.thomsonreuters.ema.access.StatusMsg; import com.thomsonreuters.ema.access.UpdateMsg; import com.thomsonreuters.ema.access.EmaFactory; import com.thomsonreuters.ema.access.OmmConsumer; import com.thomsonreuters.ema.access.OmmConsumerClient; import com.thomsonreuters.ema.access.OmmConsumerConfig; import com.thomsonreuters.ema.access.OmmConsumerEvent; import com.thomsonreuters.ema.access.OmmException; class AppClient implements OmmConsumerClient { public void onRefreshMsg(RefreshMsg refreshMsg, OmmConsumerEvent event) { System.out.println(refreshMsg); } public void onUpdateMsg(UpdateMsg updateMsg, OmmConsumerEvent event) { System.out.println(updateMsg); } public void onStatusMsg(StatusMsg statusMsg, OmmConsumerEvent event) { System.out.println(statusMsg); } public void onGenericMsg(GenericMsg genericMsg, OmmConsumerEvent consumerEvent){} public void onAckMsg(AckMsg ackMsg, OmmConsumerEvent consumerEvent){} public void onAllMsg(Msg msg, OmmConsumerEvent consumerEvent){} } public class Consumer { public static void main(String[] args) { OmmConsumer consumer = null; try { AppClient appClient = new AppClient(); OmmConsumerConfig config = EmaFactory.createOmmConsumerConfig(); consumer = EmaFactory.createOmmConsumer(config.host("host:port").username("user")); ReqMsg reqMsg = EmaFactory.createReqMsg(); consumer.registerClient(reqMsg.serviceName("service").name("JPY="), appClient); reqMsg.clear(); consumer.registerClient(reqMsg.serviceName("service").name("EUR="), appClient); reqMsg.clear(); consumer.registerClient(reqMsg.serviceName("service").name("AUD="), appClient); reqMsg.clear(); consumer.registerClient(reqMsg.serviceName("service").name("GBP="), appClient); Thread.sleep(/*1 minute*/60000 * 60 * 24 * 2 /* -> total 2 days */); // API calls onRefreshMsg(), onUpdateMsg() and onStatusMsg() } catch (InterruptedException | OmmException excp) { System.out.println(excp.getMessage()); } finally { if (consumer != null) consumer.uninitialize(); } } }