Getting started with cometd?

8 views
Skip to first unread message

Dan Scholten

unread,
Nov 2, 2006, 4:32:00 PM11/2/06
to cometd-users
How easy will it be to get a simple hello world web app up and running
with cometd? By that I mean, will cometd have java classes/methods
which I could include in an HTTPservlet, deploy it to Tomcat, then use
the dojo javascript libraries in my app to create a comet connection
and begin streaming data?

Mark Holton

unread,
Nov 2, 2006, 6:10:05 PM11/2/06
to cometd...@googlegroups.com
I'm interested in the answer to this question too.. have a potential use for CometD in the future, and would like to start trying it out, testing, etc.
Thanks guys

David Davis

unread,
Nov 2, 2006, 6:18:45 PM11/2/06
to cometd...@googlegroups.com
Are you only interested in a java implmentation of it?

I think greg could help you with that when he gets around to reading the list.

There is also a python version and a perl version in the works. I'm
working on the perl version, and will post a how-to when it's ready.

Cheers!
David

On 11/2/06, Dan Scholten <djsch...@mitre.org> wrote:
>

Alex Russell

unread,
Nov 2, 2006, 7:13:27 PM11/2/06
to cometd...@googlegroups.com, David Davis
I've you've ot a unix-like system and Python (preferably 2.5) installed,
grab an SVN checkout of the cometd-twisted trunk like this:

svn co http://svn.xantus.org/shortbus/trunk/cometd-twisted
...
cd cometd-twisted

and then run the "setup_dependencies.sh" script that that's included.
I'll wget, unpack, and set up the various twiddly python bits that you
need to run cometd.

After that, cd back into the cometd-twisted directory and type:

twistd -noy cometd.tac

and point a browser at:

localhost:8080/tests/magnets/magnets.html

Regards

> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google
> Groups "cometd-users" group. To post to this group, send email to
> cometd...@googlegroups.com To unsubscribe from this group, send
> email to cometd-users...@googlegroups.com For more options,
> visit this group at http://groups.google.com/group/cometd-users
>
> Visit the cometd website at http://www.cometd.com/
> -~----------~----~----~----~------~----~------~--~---

--
Alex Russell
al...@sitepen.com A99F 8785 F491 D5FD 04D7 ACD9 4158 FFDF 2894 6876
al...@dojotoolkit.org BE03 E88D EABB 2116 CC49 8259 CF78 E242 59C3 9723

Cat Dancer

unread,
Nov 6, 2006, 12:25:21 PM11/6/06
to cometd-users
Alex Russell wrote:
> I've you've ot a unix-like system and Python (preferably 2.5) installed,
> grab an SVN checkout of the cometd-twisted trunk like this:
>
> [ . . . ]
>
> localhost:8080/tests/magnets/magnets.html

OK, I did that, and it works, wow, pretty cool!

I am seeing an exception, <type 'exceptions.KeyError'>:
u'/meta/subscribe'. Anything to worry about?


$ twistd -noy cometd.tac
2006/11/06 12:19 EST [-] Log opened.
2006/11/06 12:19 EST [-] twistd 2.4.0 (/usr/local/bin/python 2.5.0)
starting up
2006/11/06 12:19 EST [-] reactor class: <class
'twisted.internet.selectreactor.SelectReactor'>
2006/11/06 12:19 EST [-] Loading cometd.tac...
2006/11/06 12:19 EST [-]
/usr/local/lib/python2.5/site-packages/simplejson-1.4-py2.5.egg/simplejson/scanner.py:6:
<type 'exceptions.DeprecationWarning'>: The sre module is deprecated,
please import re.
2006/11/06 12:19 EST [-] Log opened.
2006/11/06 12:19 EST [-] Loaded.
2006/11/06 12:19 EST [-] twisted.web2.channel.http.HTTPFactory starting
on 8080
2006/11/06 12:19 EST [-] Starting factory
<twisted.web2.channel.http.HTTPFactory instance at 0xb779aeac>
2006/11/06 12:19 EST [HTTPChannel,0,127.0.0.1] Exception rendering:
2006/11/06 12:19 EST [HTTPChannel,0,127.0.0.1] Traceback (most recent
call last):
File
"/usr/local/lib/python2.5/site-packages/twisted/internet/defer.py",
line 637, in gotResult
_deferGenerator(g, deferred)
File
"/usr/local/lib/python2.5/site-packages/twisted/internet/defer.py",
line 615, in _deferGenerator
deferred.callback(result)
File
"/usr/local/lib/python2.5/site-packages/twisted/internet/defer.py",
line 229, in callback
self._startRunCallbacks(result)
File
"/usr/local/lib/python2.5/site-packages/twisted/internet/defer.py",
line 294, in _startRunCallbacks
self._runCallbacks()
--- <exception caught here> ---
File
"/usr/local/lib/python2.5/site-packages/twisted/internet/defer.py",
line 307, in _runCallbacks
self.result = callback(self.result, *args, **kw)
File
"/usr/local/lib/python2.5/site-packages/twisted/web2/resource.py", line
215, in <lambda>
lambda res: self.render(request))
File "/mnt/data/in/shortbus/trunk/cometd-twisted/cometd.py",
line 436, in render
resp.append(self.route(request, m))
File "/mnt/data/in/shortbus/trunk/cometd-twisted/cometd.py",
line 616, in route
subs = root[message["channel"]]
<type 'exceptions.KeyError'>: u'/meta/subscribe'

Gloria

unread,
Dec 3, 2006, 11:35:49 PM12/3/06
to cometd-users
Looking at the magnets example, in magnets.html, you have:

function serverMagnetMoveStart(msg){
if(msg.data.source != cometd.clientId){

dojo.widget.byId(msg.data.widgetId).highlight();
}
}

Looks like you really aren't writing any data back through this channel
to the server side in any of these functions. You're just checking the
source of the incoming request. I understand why there is no supporting
server-side robustness, but this raises some questions for me.

If I had a server-side method called 'getPhrasesFromDB()' ,which had to
be invoked to populate the data structure for the dojo 'addMagnets()
function you call, how would I invoke this through CometD? Are all
messages going both ways JSON-formatted, or do I have choices? What
would the front end and back end code look like if addMagnets() called
getPhrasesFromMagnets()? How do I register getPhrasesFromMagnets() on
the server side, with CometD, so the front end knows of it's existence?
What CometD method do I invoke to write the JSON result back to the
front end?

Thank you in advance for your help,
Gloria

Gloria

unread,
Dec 3, 2006, 11:37:49 PM12/3/06
to cometd-users
To clarify, I am using Python 2.5 and your latest CometD snapshot.
Thanks again,
Gloria

Bob Carlitz

unread,
Dec 28, 2006, 12:41:42 PM12/28/06
to cometd-users
Alex's nice simple instructions don't seem to work with the latest
version from the SVN repository. An obvious little problem is that
dojo.setModulePrefix no longer exists in bootstrap1.js; I gather that
it's been replaced by dojo.registerModulePath. With this change in
magnets.html the script produces a debugging message "error loading
phrases: error" at dojo.widget.Createwidget(...). Does someone have a
working copy of the magnets example available? I would like to explore
the software further, but it's nice to have a working example to get
started with.

Thanks,
Bob

Jeremy Noetzelman

unread,
Dec 28, 2006, 1:10:50 PM12/28/06
to cometd...@googlegroups.com
I ran into similar problems.

I ended up tweaking the twisted-client Alex provided, and got that to 'sorta' work, but the server stopped passing messages after three messages.  I'm sure I messed something up though :)

Bob Carlitz

unread,
Dec 28, 2006, 1:52:08 PM12/28/06
to cometd-users
Two changes are needed in cometd-twisted/tests/magnets/magnets.html:

(1) Replace dojo.setModulePrefix by dojo.registerModulePath
(2) The first argument of dojo.widget.createWidget should be
"dojofun:Magnet", not "Magnet".

With these little changes, the demo works fine!!

Cheers!
Bob

Reply all
Reply to author
Forward
0 new messages