Search code examples
javajakarta-ee

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.

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. Is there any real=time library I should use, or should I program it from scratch using scratch, e.g. create a queue or array to store the data and delete data after the queue/array reaches a certain size?


Solution

  • I would humbly suggest that perhaps you can consider LinkedBlockingQueue (use thread/executor to read/remove the data from the 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).

    If it suits your use case, you could also look into actor libraries such as kilim or akka.