Extend - Retrieve data in real time with the Force.com streaming API
-
Upload
salesforce -
Category
Business
-
view
7.107 -
download
1
description
Transcript of Extend - Retrieve data in real time with the Force.com streaming API
![Page 1: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/1.jpg)
Retrieve Data in Real Time with the Force.com Streaming API
@alextoussaint
Alex Toussaint Director, Platform API Services [email protected]
![Page 2: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/2.jpg)
Safe Harbor Safe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of intellectual property and other litigation, risks associated with possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the most recent fiscal year ended January 31, 2010. This documents and others are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
![Page 3: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/3.jpg)
Agenda
§ The world is going Real Time! § Use Cases
§ Streaming API
§ Tips
§ Q&A
![Page 4: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/4.jpg)
Real-Time Force Initiative
User (Client Apps, Social Feeds, High
Fidelity Interaction)
Systems (Telco Apps, Internet of
Things, )
Integration (Connecting Applications
and Data Sources)
![Page 5: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/5.jpg)
Social Call Center Enable Call Center Apps to provide real time updates to service agents.
Power Social and Mobile apps to received streaming updates for real time social data.
Integration Provide real time notifications and data updates from Salesforce.
Eliminate data polling required to synchronize data.
Use Cases
Commerce & Auctions Enable Commerce show real time inventory and promotion related information – JetStream.
![Page 6: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/6.jpg)
Moving towards Real Time cloud
User Interaction
SFDC: Real Time Services
Internet of things
Presence Integration Analytics
Collection of API Services
![Page 7: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/7.jpg)
Streaming API
![Page 8: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/8.jpg)
Based on Open Technologies
§ Streaming API is GA! § Using cometD – open client technology
§ Relevancy matching is done within the save transaction – continuous queries – Events are processed by each appserver in bulk, every ~3
seconds. – Does not consume API call limits
§ Start developing now! J
![Page 9: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/9.jpg)
When would I use streaming?
§ If you are currently polling our services – Get data only when it changes
§ To receive real-time notification of new or updated data – Taking action on change in state – e.g. send alert
– Synchronize state – e.g. update page in browser
![Page 10: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/10.jpg)
Streaming vs Polling
§ Streaming – Client connects and
receives near real-time updates
– Bayeux protocol
– It does not consume API calls
– Count Events and Connections
§ Polling – Client must repeatedly call
API
– SOAP/REST APIs
– Each poll consumes at least one API call (even if data not available you pay)
![Page 11: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/11.jpg)
Streaming vs Triggers
§ Streaming – Client connects and
receives near real-time updates
– Client can be any app that can talk HTTP – server process, JavaScript in browser etc.
– Bayeux protocol
§ Trigger + future – Server must expose
endpoint to receive messages (not firewall friendly)
– Trigger is executed on data modification; may call web service via ‘future’ method
– SOAP/REST APIs
![Page 12: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/12.jpg)
Streaming API - Lifecycle
§ Administrator creates a topic based on a SOQL query – Recommend wide queries for higher fidelity
§ Client applications subscribe via the Bayeux protocol – CometD library in several languages
§ Client applications receive notifications on creates and updates that match Topic query
§ One event may get generate and sent to N clients – We count delivered events
![Page 13: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/13.jpg)
Streaming API - Logical Flow
Salesforce.com Account Contacts
Leads Opportunities
Custom Objects
App Server Manage
Subscriptions Send
Updates
1. Relevance Checks 2. Push Notification Processor 3. Event Dispatch 4. Query, CRUD, FLS Sharing
Data Changes Processing Updates Notifications
![Page 14: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/14.jpg)
Create a topic
§ Apex or API § Create PushTopic standard object
– ApiVersion, Name, Query are required fields
PushTopic pushTopic = new PushTopic();
pushTopic.ApiVersion = 2x.0;
pushTopic.Name = ’NewContacts';
pushtopic.Query = 'SELECT Id, Name, Email FROM
Contact';
insert pushTopic;
![Page 15: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/15.jpg)
Subscribe via Bayeux protocol
§ Endpoint https://hostname/cometd – Hostname is Force.com instance URL or Visualforce server
hostname
§ MUST set sid (session ID) cookie on request
$.cometd.init('https://c.na1.visual.force.com/
cometd');
var subscription = $.cometd.subscribe('/NewContacts', function(message) {
$('#content').append('<p>New record: ' +
JSON.stringify(message.data.Name) + '</p>');
});
![Page 16: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/16.jpg)
Bayeux Implementations
§ CometD client libraries exist for JavaScript and Java – cometd.org
§ Implementations also exist for other popular languages – Ruby
– Node.js – Dojo
– jQuery – PHP
– Perl
![Page 17: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/17.jpg)
Service Cloud & Streaming API Michael Ramsey Sr. Director, Salesforce - Service Cloud
![Page 18: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/18.jpg)
Service Cloud Console Universal Desktop for the Social Enterprise
Agent Experience
& Productivity
Push Avoid Navigating &
Searching
Configurable UI and Component
Framework
Contextual
• Relevant • Timely • Sufficient
Integrated 3rd Party Application & Data Integration
Platform Integrate Partner & Channel Solutions
![Page 19: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/19.jpg)
Service Cloud Console Push Notifications
§ Auto Refresh Enhanced List Views
§ Visually Markup Rows and Columns
§ Auto Refresh Detail Pages
§ Insert Message to Alert Users to Changes
![Page 20: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/20.jpg)
Push Notifications: List Views Spring ‘12
GA
![Page 21: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/21.jpg)
Push Notifications: List Views Spring ‘12
GA
![Page 22: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/22.jpg)
Spring ‘12
GA
Push Notifications: List Views
![Page 23: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/23.jpg)
UCSF Customer Project
![Page 24: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/24.jpg)
Chatter For Health Integration Architecture!
![Page 25: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/25.jpg)
Chatter For Health Message Flow!
1. Trigger creates “External_Message__c”" record"2. Mule iON subscribes to Streaming API
topic on “External_Message__c” Object 3. Mule sets status on record to “In Progress”"
4. Mule iON routes message to Amcom paging system or Twilio depending on Destination__c field"
5. Mule iON sends message back to Salesforce with “Sent” if successful or “Undelivered” if error, affixes error log"
1
5
4
3
2
![Page 26: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/26.jpg)
Tips
![Page 27: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/27.jpg)
Developing with Streaming API
§ Leverage existing CometD libraries – Existing Java, Javascript, Ruby, etc…
§ Use Firebug or equivalent to help debug – See the protocol in action, help learn behavior
§ You can listen to multiple Topics at once – One connection can listen to N topics
§ Make wide queries allow for Sharing to filter – Get all accounts, sharing will filter per user
![Page 28: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/28.jpg)
Resources
§ Force.com Streaming API – http://developer.force.com
§ Getting Started with the Force.com Streaming API – http://wiki.developerforce.com/page/Streaming_API
§ The Bayeux Protocol – http://svn.cometd.com/trunk/bayeux/bayeux.html
§ Discussion Groups – http://boards.developerforce.com/t5/Streaming-API-Developer-
Preview/bd-p/streamingapi
![Page 29: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/29.jpg)
Need more limits – contact us!
§ Customers may need more Events or Connections – Contact Salesforce Support
§ We are exploring increase overall limits for Streaming – More Connections
– More Events – What is your feedback?
![Page 30: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/30.jpg)
Q&A
![Page 31: Extend - Retrieve data in real time with the Force.com streaming API](https://reader033.fdocuments.us/reader033/viewer/2022051817/548f85f8b47959763e8b4d69/html5/thumbnails/31.jpg)
Thank You.