Solved

How to display Java realtime streaming data on website

Posted on 2011-03-07
12
783 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

746 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

10 Experts available now in Live!

Get 1:1 Help Now