It really depends on how many users and how much information you're trying to process, but here's some ballpark ideas.
On Sat, Apr 20, 2002 at 08:46:44AM +0200, Luca Ventura wrote: > Hello everybody! > > I would like implement a PUSH service in Java for my Web site. What I would > like to di is: when a user connects to my web site he can compile a form > where he chooses the type of data he wants to receive in his mailbox (eg. > newsletters about sport, culture, and so on) or in his mobile-phone (through > SMS messages) using Javamail and JMS technologies. As soon as the data that > he needs is available I can send it to him by e-mail or SMS (as he prefers). > I have some doubts about the following points: > > 1)How can I implement (in Java )the PUSH engine that collects the > preferences of the users and sends information (by e-mail and sms) to them? > I mean...must I use a servlet or a Java-program standalone always running > (in this second case I can insert a "while (true) do..." cycle in the body > so that the program never ending...)? I'd collect the information in a servlet. The push would be done by a different program. > > 2)How can I store the information about the preferences of the user? I think > I must use necessarily a dabatase: in fact the Java service (program) or the > servlet could go down (for some reason) and all the information about the > user would be lost. Am I right? Yep. Collect the info from the user and store it in the database. > > 3)How can I detect when a new type of data for the user is available and I > must send it to him? Of course I must store the data I can send to the user > in a database (that is to say the news about sport, culture, etc), but how > can I recognize when a particular type of information for a user is > available and it is time to send it to him? I though the following solution: > > a)After a fixed period of time T for every user I can periodically scan the > database where I stored the information about the news, > b) I search the type of the news that the user is looking for and I get the > up-tp-date news that I haven't sent to him yet. > c) I send the news to the user. > > Anyway in this solution I have the following problems: > > 1) I can have thousands of users and of news in the database: so I have to > do thousands of searches in the database after a period T (this can take > seconds, minute, or hours) even if there is no new information to send to > any user, and this isn't very efficient. Maybe the best solution would be to > detect when a new information is inserted in the "database of the news" and > only in that moment to search for the user that need it, or not? > > 2) In this second case....how can I listen (detect) when a new "information" > arrives and is stored in the database? > > 3) I could search for the users to whom to send new data WHEN I am sure a > new information is arrived AND AT LEAST WHEN a fixed period of time T is > passed (I would combine the two techniques): in this way I could reduce the > overhead fo the searches in the database. What do you think about? > > 4) How can get from the "database" ONLY that news I haven't already sent to > the user? I think wouldn't be a good idea to send to the user two times the > same news!! You're not saying how the data gets to you, how big it is, how often you want to send email to your users. If new info comes in every 5 minutes, will your users really want to get the email every 5 minutes or would they want it collected and sent as a digest? It's not clear that you even want to store the news in the database. You might just want to grab it as it comes in, (how is it coming in, anyway?) and send it to the users that want it and dump the rest. That would make sense, for instance if you're getting 250Megs of data /hour and you're only feeding your users 1 Meg /hour. Why store the other 249 Meg that you don't need. As far as looking up thousands of records in the database, that's not really a problem. The database can look up thousands of rows in seconds as long as the data is not really big. > > > Given that to implement a push engine is very difficult any hint (and any > useful link) on the argument is appreciated. > > I thank you for the help and the patience in advance. > > Luca > > ___________________________________________________________________________ > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body > of the message "signoff SERVLET-INTEREST". > > Archives: http://archives.java.sun.com/archives/servlet-interest.html > Resources: http://java.sun.com/products/servlet/external-resources.html > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html > > -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
