public ConsumerInstance(String host, String username) { _appClient = new AppClient(); _reqMsg = EmaFactory.createReqMsg(); _consumer = EmaFactory.createOmmConsumer(EmaFactory.createOmmConsumerConfig().host(host).username(username)); _executor = Executors.newSingleThreadExecutor(); _executor.execute(this); }
public void onStatusMsg(StatusMsg statusMsg, OmmConsumerEvent event) { System.out.println("Handle: " + event.handle()); System.out.println("Parent Handle: " + event.parentHandle()); System.out.println("Closure: " + event.closure()); System.out.println(statusMsg); if (!_subItemOpen && event.handle() == _tunnelStreamHandle && statusMsg.hasState() && statusMsg.state().streamState() == OmmState.StreamState.OPEN) { _subItemOpen = true; _ommConsumer.registerClient(EmaFactory.createReqMsg().name("TUNNEL_IBM").serviceId(1), this, 1, _tunnelStreamHandle); } System.out.println(); }
public static void main(String[] args) { OmmConsumer consumer = null; try { AppClient appClient = new AppClient(); consumer = EmaFactory.createOmmConsumer(EmaFactory.createOmmConsumerConfig().consumerName("Consumer_2")); consumer.registerClient( EmaFactory.createReqMsg().serviceName("DIRECT_FEED").name("IBM.N"), appClient, 0); Thread.sleep(60000); // API calls onRefreshMsg(), onUpdateMsg() and onStatusMsg() } catch (InterruptedException | OmmException excp) { System.out.println(excp.getMessage()); } finally { if (consumer != null) consumer.uninitialize(); } } }
public static void main(String[] args) { OmmConsumer consumer = null; try { AppClient appClient = new AppClient(); consumer = EmaFactory.createOmmConsumer(EmaFactory.createOmmConsumerConfig().host("localhost:14002").username("user")); consumer.registerClient(EmaFactory.createReqMsg().serviceName("DIRECT_FEED").name("IBM.N"), appClient, consumer); Thread.sleep(60000); // API calls onRefreshMsg(), onUpdateMsg() and onStatusMsg() } catch (InterruptedException | OmmException excp) { System.out.println(excp.getMessage()); } finally { if (consumer != null) consumer.uninitialize(); } } }
public static void main(String[] args) { OmmConsumer consumer = null; try { AppClient appClient = new AppClient(); consumer = EmaFactory.createOmmConsumer(EmaFactory.createOmmConsumerConfig().config( createProgramaticConfig())); // use programmatic configuration parameters consumer.registerClient(EmaFactory.createReqMsg().serviceName("DIRECT_FEED").name("IBM.N"), appClient); Thread.sleep(60000); // API calls onRefreshMsg(), onUpdateMsg() and onStatusMsg() } catch (InterruptedException | OmmException excp) { System.out.println(excp.getMessage()); } finally { if (consumer != null) consumer.uninitialize(); } } }
public static void main(String[] args) { OmmConsumer consumer = null; try { AppClient appClient = new AppClient(); consumer = EmaFactory.createOmmConsumer(EmaFactory.createOmmConsumerConfig().host("localhost:14002").username("user")); consumer.registerClient(EmaFactory.createReqMsg().serviceName("DIRECT_FEED").name("IBM.N"), appClient); Thread.sleep(60000); // API calls onRefreshMsg(), onUpdateMsg() and onStatusMsg() } catch (InterruptedException | OmmException excp) { System.out.println(excp.getMessage()); } finally { if (consumer != null) consumer.uninitialize(); } } }
public static void main(String[] args) { OmmConsumer consumer = null; try { AppClient appClient = new AppClient(); consumer = EmaFactory.createOmmConsumer(EmaFactory.createOmmConsumerConfig().host("localhost:14002").username("user")); consumer.registerClient( EmaFactory.createReqMsg().serviceName("DIRECT_FEED").name("IBM.N"), appClient, 0); Thread.sleep(60000); // API calls onRefreshMsg(), onUpdateMsg() and onStatusMsg() } catch (InterruptedException | OmmException excp) { System.out.println(excp.getMessage()); } finally { if (consumer != null) consumer.uninitialize(); } } }
public static void main(String[] args) { OmmConsumer consumer = null; try { AppClient appClient = new AppClient(); consumer = EmaFactory.createOmmConsumer(EmaFactory.createOmmConsumerConfig().host("localhost:14002").username("user")); consumer.registerClient(EmaFactory.createReqMsg().domainType(200).serviceName("DIRECT_FEED").name("IBM.XYZ"), appClient, 0); Thread.sleep(60000); // API calls onRefreshMsg(), onUpdateMsg() and onStatusMsg() } catch (InterruptedException | OmmException excp) { System.out.println(excp.getMessage()); } finally { if (consumer != null) consumer.uninitialize(); } } }
public static void main(String[] args) { OmmConsumer consumer = null; try { AppClient appClient = new AppClient(); consumer = EmaFactory.createOmmConsumer(EmaFactory.createOmmConsumerConfig().host("localhost:14002").username("user")); consumer.registerClient(EmaFactory.createReqMsg().domainType(EmaRdm.MMT_SYMBOL_LIST).serviceName("ELEKTRON_DD").name(".AV.N"), appClient, 0); Thread.sleep(60000); // API calls onRefreshMsg(), onUpdateMsg() and onStatusMsg() } catch (InterruptedException | OmmException excp) { System.out.println(excp.getMessage()); } finally { if (consumer != null) consumer.uninitialize(); } } }
public static void main(String[] args) { OmmConsumer consumer = null; try { AppClient appClient = new AppClient(); consumer = EmaFactory.createOmmConsumer(EmaFactory.createOmmConsumerConfig().host("localhost:14002").username("user")); // request a custom domain (133) item IBM.XYZ consumer.registerClient(EmaFactory.createReqMsg().domainType(133).serviceName("DIRECT_FEED").name("IBM.XYZ"), appClient, 1); Thread.sleep(60000); // API calls onRefreshMsg(), onUpdateMsg() and onStatusMsg() } catch (InterruptedException | OmmException excp) { System.out.println(excp.getMessage()); } finally { if (consumer != null) consumer.uninitialize(); } } }
public static void main(String[] args) { OmmConsumer consumer = null; try { AppClient appClient = new AppClient(); consumer = EmaFactory.createOmmConsumer(EmaFactory.createOmmConsumerConfig().host("localhost:14002").username("user")); consumer.registerClient( EmaFactory.createReqMsg().domainType(EmaRdm.MMT_MARKET_BY_ORDER) .serviceName("DIRECT_FEED").name("AAO.V"), appClient, 0); Thread.sleep(60000); // API calls onRefreshMsg(), onUpdateMsg() and onStatusMsg() } catch (InterruptedException | OmmException excp) { System.out.println(excp.getMessage()); } finally { if (consumer != null) consumer.uninitialize(); } } }
public static void main(String[] args) { OmmConsumer consumer = null; try { AppClient appClient = new AppClient(); consumer = EmaFactory.createOmmConsumer(EmaFactory.createOmmConsumerConfig().host("localhost:14002").username("user")); consumer.registerClient(EmaFactory.createReqMsg().domainType(EmaRdm.MMT_MARKET_BY_ORDER) .serviceName("DIRECT_FEED").name("AAO.V"), appClient); Thread.sleep(60000); // API calls onRefreshMsg(), onUpdateMsg() and onStatusMsg() } catch (InterruptedException | OmmException excp) { System.out.println(excp.getMessage()); } finally { if (consumer != null) consumer.uninitialize(); } } }
public static void main(String[] args) { OmmConsumer consumer = null; try { AppClient appClient = new AppClient(); consumer = EmaFactory.createOmmConsumer(EmaFactory.createOmmConsumerConfig().host("localhost:14002").username("user")); appClient.setOmmConsumer(consumer); consumer.registerClient(EmaFactory.createReqMsg().serviceName("DIRECT_FEED").name("IBM.N"), appClient, 0); Thread.sleep(60000); // API calls onRefreshMsg(), onUpdateMsg() and onStatusMsg() } catch (InterruptedException | OmmException excp) { System.out.println(excp.getMessage()); } finally { if (consumer != null) consumer.uninitialize(); } } }
public static void main(String[] args) { OmmConsumer consumer = null; try { AppClient appClient = new AppClient(); consumer = EmaFactory.createOmmConsumer(EmaFactory.createOmmConsumerConfig().host("localhost:14002").username("user"), appClient); ReqMsg reqMsg = EmaFactory.createReqMsg(); consumer.registerClient(reqMsg.clear().serviceName("DIRECT_FEED").name("IBM.N"), appClient); Thread.sleep(60000); // API calls onRefreshMsg(), onUpdateMsg() and onStatusMsg() } catch (InterruptedException | OmmException excp) { System.out.println(excp.getMessage()); } finally { if (consumer != null) consumer.uninitialize(); } } }
public void onUpdateMsg(UpdateMsg updateMsg, OmmConsumerEvent event) { System.out.println("Item Name: " + (updateMsg.hasName() ? updateMsg.name() : "<not set>")); System.out.println("Service Name: " + (updateMsg.hasServiceName() ? updateMsg.serviceName() : "<not set>")); if (DataType.DataTypes.FIELD_LIST == updateMsg.payload().dataType()) decode(updateMsg.payload().fieldList()); System.out.println(); if(updateMsg.domainType() == EmaRdm.MMT_MARKET_PRICE) { if(++_updateCount == 10) { System.out.println("Pausing all item streams"); _ommConsumer.reissue(EmaFactory.createReqMsg().domainType(EmaRdm.MMT_LOGIN).initialImage(false).pause(true).name("user"), _loginHandle); } } }
public static void main(String[] args) { OmmConsumer consumer = null; try { AppClient appClient = new AppClient(); consumer = EmaFactory.createOmmConsumer(EmaFactory.createOmmConsumerConfig().operationModel(OperationModel.USER_DISPATCH).host("localhost:14002").username("user")); consumer.registerClient(EmaFactory.createReqMsg().serviceName("DIRECT_FEED").name("N2_UBMS"), appClient, 0); long startTime = System.currentTimeMillis(); while (startTime + 60000 > System.currentTimeMillis()) consumer.dispatch(10); // calls to onRefreshMsg(), onUpdateMsg(), or onStatusMsg() execute on this thread } catch (OmmException excp) { System.out.println(excp); } finally { if (consumer != null) consumer.uninitialize(); } } }
public void onRefreshMsg(RefreshMsg refreshMsg, OmmConsumerEvent event) { System.out.println("Received Refresh. Item Handle: " + event.handle() + " Closure: " + event.closure()); System.out.println("Item Name: " + (refreshMsg.hasName() ? refreshMsg.name() : "<not set>")); System.out.println("Service Name: " + (refreshMsg.hasServiceName() ? refreshMsg.serviceName() : "<not set>")); System.out.println("Item State: " + refreshMsg.state()); if (DataType.DataTypes.FIELD_LIST == refreshMsg.payload().dataType()) decode( refreshMsg.payload().fieldList() ); if (refreshMsg.state().streamState() == OmmState.StreamState.OPEN && refreshMsg.state().dataState() == OmmState.DataState.OK && !hasFirstRefresh ) { _ommConsumer.reissue(EmaFactory.createReqMsg().priority(2, 2), event.handle()); hasFirstRefresh = true; } System.out.println(); }
public static void main(String[] args) { AppClient appClient = new AppClient(); AppErrorClient appErrorClient = new AppErrorClient(); OmmConsumer consumer = EmaFactory.createOmmConsumer(EmaFactory.createOmmConsumerConfig() .operationModel(OperationModel.USER_DISPATCH) .username("user"), appErrorClient); long invalidHandle = 0; consumer.reissue(EmaFactory.createReqMsg(), invalidHandle); consumer.submit(EmaFactory.createGenericMsg(), invalidHandle); consumer.submit(EmaFactory.createPostMsg(), invalidHandle); consumer.registerClient(EmaFactory.createReqMsg().serviceName("DIRECT_FEED").name("IBM.N"), appClient); long startTime = System.currentTimeMillis(); while (startTime + 60000 > System.currentTimeMillis()) consumer.dispatch(10); // calls to onRefreshMsg(), onUpdateMsg(), or onStatusMsg() execute on this thread consumer.uninitialize(); } }
public void onRefreshMsg(RefreshMsg refreshMsg, OmmConsumerEvent event) { System.out.println("Received Refresh. Item Handle: " + event.handle() + " Closure: " + event.closure()); decode(refreshMsg); // open a sub stream (a.k.a. nested message request) if (refreshMsg.state().streamState() == OmmState.StreamState.OPEN && refreshMsg.state().dataState() == OmmState.DataState.OK && refreshMsg.domainType() == 200) { ReqMsg reqMsg = EmaFactory.createReqMsg(); reqMsg.name(".DJI").privateStream(true).serviceId(refreshMsg.serviceId()).streamId(1); _ommConsumer.submit(EmaFactory.createGenericMsg().payload(reqMsg), event.handle()); } System.out.println(); }
@Test public void decodeLoginReqInvalidTypeTest() { ElementList encodedElementList = EmaFactory.createElementList(); encodedElementList.add( EmaFactory.createElementEntry().ascii(EmaRdm.ENAME_ALLOW_SUSPECT_DATA, "1")); com.thomsonreuters.upa.codec.DataDictionary dictionary = com.thomsonreuters.upa.codec.CodecFactory .createDataDictionary(); TestUtilities.upa_encodeDictionaryMsg(dictionary); ReqMsg encReqMsg = EmaFactory.createReqMsg(); encReqMsg.domainType(EmaRdm.MMT_LOGIN); encReqMsg.attrib(encodedElementList); ReqMsg decReqMsg = JUnitTestConnect.createReqMsg(); JUnitTestConnect.setRsslData(decReqMsg, encReqMsg, Codec.majorVersion(), Codec.minorVersion(), dictionary, null); exception.expect(OmmInvalidUsageException.class); exception.expectMessage("Decoding error for AllowSuspectData element. Attempt to uintValue() while actual entry data type is Ascii"); LoginReq loginReq = EmaFactory.Domain.createLoginReq(); loginReq.message(decReqMsg); }