Solved

How to display Java realtime streaming data on website

Posted on 2011-03-07
12
792 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Python Assistance 7 73
Responding to Java JComponent extended classes's resize event 4 52
maven project error 5 48
netstat -ano | find "8000" and taskkill /f /pid 2984 3 38
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
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…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to implement Singleton Design Pattern in Java.

867 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

16 Experts available now in Live!

Get 1:1 Help Now