Apex Callouts and Outbound Messaging are great ways to get your data outside of salesforce.com for integration with external system. However, there are times when you are going to bump into Callout Limits or would like to use Outbound Messaging with non-SOAP endpoints. Never fear, for these types of situations the Force.com Streaming API comes to your rescue!
The Force.com Streaming API lets you expose a near real-time stream of data from the Force.com platform in a secure and scalable way to external applications. From the docs,
The Force.com Streaming API uses a publish/subscribe model where administrators create one or more named topics, each of which is associated with a SOQL query. Applications may subscribe to one or more topics, using the Bayeux protocol. As relevant data is updated, the platform re-evaluates the query and, when a change occurs that alters the results of the query, the platform publishes a notification to subscribed applications.
I've put together a video and demo application (see below) that walks you through the entire process. Feel free to clone the github repo and use the code for your own project. All of the instructions to setup and run the application are on the repo.
Here's an overview of the application. I setup a PushTopic in salesforce.com that streams newly created Account records to a Node application running on heroku using faye (a publish-subscribe messaging system based on the Bayeux protocol) to listen for new records. When a new record is received, it is written to the browser using socket.io without a page refresh (I know.... magic!!). You could use this same paradigm to send the records to an external HR system, account system or possibly email server. The sky's the limit.
Run the Demo Application
Feel free to watch the entire video at Youtube or embedded below, but here's how to run the demo yourself:
Open this page in another browser window. This is a simple Node app that allows you to create a new Account record in my DE org.
Open the demo app in another browser window. This page will initially be blank but as you (or anyone else) adds new Account records in the first app, they will appear on this page.
Here's a video of the entire process but you can watch it on Youtube if that's more convenient.
Like code? If so, here's the main app.js from the repo: