Thanks for you reply!!!

So what you told me is:

1) I get the preferences that the user insert in a form using a Servlet
(that is to say the form is sent to the servlet).

2)I store the preferences of the user in a database (as I do with the
"news").


Did I understand well?

How must I implement my push program? Must it be a Java program stand-alone
running forever and that everytime do the following operations?

a) connects to the database of the news.
b) Check if some news are arrived.
c) Find the user that need that news.
d) Send the news to the users.


Is this correct?

About your doubts:

1) The data can get to me in different ways:

   a) I can't insert the data manually in my database;
   b) The data can be inserted in my database by a procedure (or program)
that retrieve it   from other data sources, external to my application.

2) The size of data can be very large (for example sufficient to store
articles, in this case I could send to the users only an abstract of every
article)

3)I don't know WHEN new info arrive exactly (it could arrive after minutes
or hours): in this case what do you suggest to me to do? To collect it and
send it to the users after a fixed period of time?

Some other doubts:

1) What do you mean with "digest"?

2) Do you think it is a good idea to let the user choose the time period
after that he wants to rececive the notifications?

3) How can I detect and dump that information that the users don't want?
Some new users could arrive and could want the information I dumped!

4) How would you implement the push-service and activate it? Would you use
J2EE API
and build the Java service as a Java program standalone?

Let me know, please.

Thanks a lot in advance!!

                             Luca


-----Messaggio originale-----
Da: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]Per conto di Dror
Matalon
Inviato: sabato 20 aprile 2002 8.54
A: [EMAIL PROTECTED]
Oggetto: Re: How can I implement a PUSH service in Java?


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

___________________________________________________________________________
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

Reply via email to