简体   繁体   English

我应该如何处理获取实时数据,将其存储在Java类型中以及绘制实时图表?

[英]How should I handle getting real-time data, storing it in a Java type, and plotting a real-time graph?

What is the best procedure for reading real time data from a socket and plotting it in a graph? 从套接字读取实时数据并将其绘制在图表中的最佳步骤是什么? Graphing isn't the issue for me; 图形化对我来说不是问题; my question is more related to storing the stream of data, which gets updated via a port. 我的问题与存储数据流有关,后者通过端口进行更新。 Java needs to be able to read and parse it in a queue, array, or hash map and thus plot the real time graph. Java需要能够在队列,数组或哈希映射中读取和解析它,从而绘制实时图形。

The complication here is that the app can get a large amount of data every second. 这里的复杂之处在于应用程序每秒都可以获取大量数据。 Java needs to do some high-performance job to parse the data, clean the old records, and add new records continuously. Java需要做一些高性能的工作来解析数据,清理旧记录,并不断添加新记录。 Is there any real=time library I should use, or should I program it from scratch using scratch, eg create a queue or array to store the data and delete data after the queue/array reaches a certain size? 是否有我应该使用的真实时间库,或者我应该从头开始使用临时编程,例如创建一个队列或数组来存储数据并在队列/数组达到一定大小后删除数据?

I would humbly suggest that perhaps you can consider LinkedBlockingQueue (use thread/executor to read/remove the data from the LinkedBlockingQueue). 我谦虚地建议你也许可以考虑使用LinkedBlockingQueue(使用线程/执行器来读取/删除LinkedBlockingQueue中的数据)。

If you do not wish to use these data structures but prefer a messaging server to take on that responsibility for some reason, ActiveMQ/ZMQ/RabbitMQ etc would help out (with either queues or topics depending on your use case - for instance in AMQ, use queue for one consumer, topic for multiple consumers unless you wish to use browsers with durable queues). 如果您不希望使用这些数据结构,但是由于某些原因而更喜欢消息传递服务器承担这一责任,那么ActiveMQ / ZMQ / RabbitMQ等会提供帮助(根据您的使用情况,使用队列或主题 - 例如在AMQ中,为一个使用者使用队列,为多个使用者使用主题,除非您希望使用具有持久队列的浏览器)。

If it suits your use case, you could also look into actor libraries such as kilim or akka. 如果它适合您的用例,您还可以查看诸如kilim或akka之类的actor库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM