Summer of APIs: Force.com Streaming API Webinar

As Quinton blogged last week, this is the Summer of APIs here at Force.com. Hard on the heels of the Chatter REST API preview webinar (well, nine days later, but who’s counting?), Alex Toussaint and I will be presenting the Force.com Streaming API preview webinar on July 7th, at the usual times of 7am and 10am Pacific.

So, what is the Streaming API? Well, if you’ve ever written code to periodically poll an existing Force.com API for new records or changes to existing records, the Streaming API offers a more elegant, efficient, scalable alternative. Given a SOQL query, you can create a topic to which applications can subscribe for updates via the the Bayeux protocol, available as an open source implementation courtesy of the CometD project.

To whet your appetite, here is the code for a sample Visualforce page that subscribes to a topic and displays updates as they arrive:







(function($){
$(document).ready(function() {
//Connect to the appropriate server.
$.cometd.init('https://'+window.location.hostname+'/cometd');
// Subscribe to a topic. JSON-encoded update will be returned
// in the callback
$.cometd.subscribe('/NewAccounts', function(message) {
$('#content').append('

'+JSON.stringify(message)+'

'); }); }); })(jQuery)

Notifications should appear here...

That’s it, in its entirety – a handful of script includes, then two calls to the CometD jQuery binding and a callback to catch the updates. Here it is in action:

Of course, that’s an absolutely minimal sample – to discover how to design queries, create topics, and get all this working with applications outside the platform, join us for the webinar. Register here – space is, as they say, limited.

(Detail of the Bayeux Tapestry by elyob (original image). Used under the terms of the Creative Commons Attribution-ShareAlike 2.0 Generic license)

Published
June 21, 2011
Topics:

Leave your comments...

Summer of APIs: Force.com Streaming API Webinar