void init() { for (int i = 0; i < threads; i++) { esOrderConsumer.execute(new PositionQueueSlurper()); } topicFeed.addMessageListener(new StockStreamListener()); mapNewOrders.addLocalEntryListener(new NewOrderListener()); startStreamer(); Executors.newSingleThreadExecutor() .execute( new Runnable() { public void run() { while (true) { try { Thread.sleep(5000); long feeds = countReceivedStockUpdates.getAndSet(0) / 5; long orders = countOrdersProcessed.getAndSet(0) / 5; long events = countNewOrderEvents.getAndSet(0) / 5; long views = countPositionViews.getAndSet(0) / 5; log( "Feeds:" + feeds + ", OrdersProcessed:" + orders + ", newOrderEvents:" + events + ", Views:" + views); } catch (Exception e) { e.printStackTrace(); } } } }); }
/** * Constructs the topic listener which will listen on the given topic. * * @param topic the topic to listen to */ public HzTopicListener(ITopic<byte[]> topic) { this.queue = QueueTopicProxyFactory.createQueueProxy( new ArrayBlockingQueue<byte[]>(config.getTopicMaxMessageCount())); this.msgTopic = topic; registrationId = topic.addMessageListener(this); }