users@grizzly.java.net

comet throttling

From: Cam Bazz <cambazz_at_gmail.com>
Date: Sun, 6 Jul 2008 00:22:47 +0300

Hello,

Now my comet application has matured a bit, I would like to add functions of
throttling. So far, I used an EJB Timer bean to notify the comet context,
pushing data to every client at the same time.

I successfully used context.getCometHandlers().size() to get the number of
active users at a given time. (although, it does not work properly in IE,
but it is probably unrelated - IE will get comet response immediately when
you issue a get request to the servlet, it wont wait until notification is
sent)

I was thinking one could get an iterator over getCometHandlers, wait a while
and notify each client individually in a round robin fashion. However, this
has a drawback, as the number of users increase, the notification interval
also increases.

Then I found at Jean's blog about throttling:
http://weblogs.java.net/blog/jfarcand/archive/2007/03/new_adventures_1.html

I understand you implement NotificationHandler in your comet handler which
gives you the following methods:

    public boolean isBlockingNotification();
    /**
     * Set to true if the invoker of notify() should block when
     * notifying Comet Handlers.
     */
    public void setBlockingNotification(boolean blockingNotification);
    /**
     * Notify all CometHandler.
     * @param cometEvent the CometEvent used to notify CometHandler
     * @param iteratorHandlers An iterator over a list of CometHandler
     */
    public void notify(CometEvent cometEvent,Iterator<CometHandler>
iteratorHandlers)
        throws IOException;
    /**
     * Notify a single CometHandler
     * @param cometEvent the CometEvent used to notify CometHandler
     * @param iteratorHandlers An iterator over a list of CometHandler
     */
    public void notify(CometEvent cometEvent,CometHandler cometHandler)


it is almost what I want, but I could not come up with a logic to use the
code. Are there any examples about this? how can we implement a logic that
smoothly notifies all the clients in a round robin fashion?

Best Regards,
-C.B.