Wednesday, May 2, 2012

Oh Streaming API... How We Love Thee

Here at CloudSpokes we love the Streaming API. If you haven't had a chance to work with the API yet... well shame on you. Not only is it cool but it's extremely easy to work with. Pick your  implementation of CometD (aka Bayeux protocol) in your favorite language, create a PushTopic for the records you want to stream and you are in business!

We launched our Streaming Chatter Feeds challenge to build an application that streams a user's chatter feed to the browser using the Streaming API and CometD. Sure, we could have done this by polling the Chatter objects but we wanted to be cool. Unfortunately does not allow you to create PushTopic with Chatter objects. Needless to say... we were sad at this discovery. However, the crowd comes through once again riding in on a mighty surfboard and saves the day!

We had two submissions that were worthy of money and took totally different routes to achieve the same results.

First, peakpado built his entry in Java using RabbitMQ on Heroku (take a peek at his video). Since Chatter doesn’t support the streaming API, he created three triggers on the Chatter objects. When Chatter is created, the trigger creates one entry on the custom object Chatter_Stream__c, where PushTopic is listening on. Whenever Chatter_Stream__c object is created, it’s streamed down to the streaming clients. This user_id is used to filter the Chatters for user so that only chatters belongs to the user is published to the client. It also queries group membership, so only chatter from the group user belongs to is published to the client.

Avidev9 went the 100% route using Visualforce and calling back to itself using the REST API for chatter from an iframed Visualforce page. Very ingenious!

peakpado - video
Place: 1
Money: $500
Place: 1
Money: $500

1 comment:

  1. Ohh I was so busy with work that I missed on this, I could have easily done this as I have developed something really similar. You can read my solution @ my blog -