Solved

How to display Java realtime streaming data on website

Posted on 2011-03-07
12
799 Views
Last Modified: 2012-05-11
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.
0
Comment
Question by:orazen12
  • 5
  • 4
  • 3
12 Comments
 
LVL 47

Expert Comment

by:for_yan
ID: 35055209
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.
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 300 total points
ID: 35055292
You'll need to use something like Ajax to do that, e.g.

http://www.codeproject.com/KB/ajax/AJAX_DataGrid.aspx
0
 

Author Comment

by:orazen12
ID: 35055307
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.
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 86

Expert Comment

by:CEHJ
ID: 35055396
The important element  here is that part of the page will need to be refreshed - hence Ajax
0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 200 total points
ID: 35055779
Yes, Ajax is probably the fanciest way to do it; I guess, you can also do it with an applet, where you can specify the ticker symbol and the applet can then at some intervals contact the server (provided that it is loaded from the web server on the same host) get the current number and  display it;   you can also make a servlet and include a javascript on the page which will trigger refresh of the page after certain time and refreshed servlet  will come with a new value; that would probably be more awkward way of doing it, and refresh will be slower.
0
 

Author Comment

by:orazen12
ID: 35055781
CEHJ,
I am not storing the data in a database. Can I still use AJAX?
0
 
LVL 47

Expert Comment

by:for_yan
ID: 35055857
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.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35055941
Yes, Ajax is a means of refreshing data. It doesn't care where it is or how persistent it is
0
 

Author Comment

by:orazen12
ID: 35056095
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.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35060380
This is atypical pattern: http://ajaxpatterns.org/Periodic_Refresh
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35068538
:)
0
 

Author Comment

by:orazen12
ID: 35068593
Thanks CEHJ and For_Yan
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now