Comet Update for long running ajax calls to same browser?

63 views
Skip to first unread message

Torsten Uhlmann

unread,
Apr 28, 2012, 8:53:02 AM4/28/12
to Lift
Hi all,

I have a question whether it makes sense to use Comet's partialUpdate
or rather plain Ajax in the following situation:

On our site, the user can enter some piece of information which is
then ajax send to the server. Currently the call immediately returns,
which is desired.

On the server side some processing is done with that data in a
separate thread and when done the data is sent to a Comet Actor.

This actor then sends the data to the requesting user, and only to
him. There is no need to send the data to other browsers.

I choose Comet Actor for this because it takes a few seconds to
process the data, which I wanted to be done in a different thread. The
user can continue to work and when the processing is complete the data
appears in his browser.

Is that a use case for Comet (because it's only pushed to the same
browser it came from) or should I resort to plain Ajax? What's the
processing overhead for comet because it's send to every comet
listener?

If I should do that with plain Ajax, can I still process the request
in a different thread and answer the ajax call when complete?

Thanks for your help!

Torsten.

David Pollak

unread,
Apr 28, 2012, 4:51:49 PM4/28/12
to lif...@googlegroups.com
Having a CometActor per page is the right approach... and having a randomly named comet actor per page is better so that you'll have a different instance per page.

I don't understand how CometListener works into the design.  Why not just send the message directly from the Ajax handler to the CometActor associated with the page that the Ajax request came from?


Torsten.

--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code



--
Visi.Pro, Cloud Computing for the Rest of Us http://visi.pro
Lift, the simply functional web framework http://liftweb.net


AGYNAMIX Torsten Uhlmann

unread,
Apr 29, 2012, 2:32:05 AM4/29/12
to lif...@googlegroups.com
Thanks heaps for your response, and thanks for the hint with the randomly named CometActor per page.

Now, how do I sent a message to the CometActor associated with the page the request came from?

We currently have something like this:

class NotificationsActor extends CometListener 

That thing registers with a NotificationServer to whom I sent the messages. How would I send the message to the Actor directly, do I just keep a reference in a RequestVar?

Thanks,
Torsten.

-- 
AGYNAMIX(R). Passionate Software.
Inh. Torsten Uhlmann | Buchenweg 5 | 09380 Thalheim
Phone:       +49 3721 273445
Fax:             +49 3721 273446
Mobile:       +49 151 12412427
Web:           http://www.agynamix.de

Torsten Uhlmann

unread,
Apr 30, 2012, 5:19:08 AM4/30/12
to Lift
I've read into Diego's description here: http://blog.fmpwizard.com/54204619

I'm now setting a random name to my actor and i save that name in a
RequestVar and later I use

LiftSession.sendCometActorMessage(<Actor Type>, <Actor Name>,
<Message>)

to shoot the message only to that one actor.

I hope that's somewhat a sane approach.

Thanks,
Torsten.

On 29 Apr., 08:32, AGYNAMIX Torsten Uhlmann <T.Uhlm...@agynamix.de>
wrote:
> Thanks heaps for your response, and thanks for the hint with the randomly named CometActor per page.
>
> Now, how do I sent a message to the CometActor associated with the page the request came from?
>
> We currently have something like this:
>
> class NotificationsActor extends CometListener
>
> That thing registers with a NotificationServer to whom I sent the messages. How would I send the message to the Actor directly, do I just keep a reference in a RequestVar?
>
> Thanks,
> Torsten.
>
> --
> AGYNAMIX(R). Passionate Software.
> Inh. Torsten Uhlmann | Buchenweg 5 | 09380 Thalheim
> Phone:       +49 3721 273445
> Fax:             +49 3721 273446
> Mobile:       +49 151 12412427
> Web:          http://www.agynamix.de
>
> Am 28.04.2012 um 22:51 schrieb David Pollak:
>
>
>
>
>
>
>
> > Having a CometActor per page is the right approach... and having a randomly named comet actor per page is better so that you'll have a different instance per page.
>
> > I don't understand how CometListener works into the design.  Why not just send the message directly from the Ajax handler to the CometActor associated with the page that the Ajax request came from?
>
> > Visi.Pro, Cloud Computing for the Rest of Ushttp://visi.pro
> > Lift, the simply functional web frameworkhttp://liftweb.net

Diego Medina

unread,
Apr 30, 2012, 7:30:53 AM4/30/12
to lif...@googlegroups.com


>
> I hope that's somewhat a sane approach.

Of course it is :) Joke side, I really think that this method does not have any negative side effects.

Regards
Diego

Reply all
Reply to author
Forward
0 new messages