orazen12
asked on
How to display Java realtime streaming data on website
Hi,
I have an application where I'm continuously generating some numbers based on some formula. Say about 50 numbers every second. I'm not storing these numbers in any database and would like to display it on my website. To get a better idea an example of a website with streaming stock prices can be taken. The technology I'm using is Java. I'm also planning to use Spring (still need to learn Spring though).
Please let me know how I can do the same.
Thanks.
I have an application where I'm continuously generating some numbers based on some formula. Say about 50 numbers every second. I'm not storing these numbers in any database and would like to display it on my website. To get a better idea an example of a website with streaming stock prices can be taken. The technology I'm using is Java. I'm also planning to use Spring (still need to learn Spring though).
Please let me know how I can do the same.
Thanks.
Well, this seems very general question, but basically you may store your numbers say vs time when you received them in the ArrayList (in case your time ointervals are all the time the same) or HashMap otherwise, then maybe manipulate them in some way to create data for particular plot, and the use say JFreeChart package to create your plot,and say redraw it every minute and create say jpeg file and show it in your servlet. You can also make it an applet or even non-web oriented client-server application, like several well-known stock-trading packages. If you generate 50 numbers per second those would be 180000 numbers per hour, so in 24 hours that will still be something you can hold in memory. You may probably want to save your data to database from time to time.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your reply For_yan.
I should have been more specific. I do not need to display a graph. As I mentioned, it should be looked at as a stock price streaming data. So the 50 numbers I am generating are independent of each other and each one corresponds to a specific key (stock ticker). The numbers will be displayed only if the specific ticker is selected. The prices are not being stored anywhere. The user can at anytime connect to the website and start getting the live prices till the time he/she is connected. Because I do not need the historical numbers (prices) so I am not storing them.
I should have been more specific. I do not need to display a graph. As I mentioned, it should be looked at as a stock price streaming data. So the 50 numbers I am generating are independent of each other and each one corresponds to a specific key (stock ticker). The numbers will be displayed only if the specific ticker is selected. The prices are not being stored anywhere. The user can at anytime connect to the website and start getting the live prices till the time he/she is connected. Because I do not need the historical numbers (prices) so I am not storing them.
The important element here is that part of the page will need to be refreshed - hence Ajax
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
CEHJ,
I am not storing the data in a database. Can I still use AJAX?
I am not storing the data in a database. Can I still use AJAX?
I guess, for Ajax you need to provide data as a web service, it should not matter whether it ultimately comes from the database or from any other source.
Yes, Ajax is a means of refreshing data. It doesn't care where it is or how persistent it is
ASKER
So as I understand, I can use the same technique to fetch even the static data (like a snapshot in any point of time) with a large time gap between two consecutive fetches.
That sounds good. Would you be able to provide a reference to a website so that I can search for the right thing.
Thanks.
That sounds good. Would you be able to provide a reference to a website so that I can search for the right thing.
Thanks.
This is atypical pattern: http://ajaxpatterns.org/Periodic_Refresh
:)
ASKER
Thanks CEHJ and For_Yan