build your first real-time app with the streaming api

22
Build your first Real-Time App with Streaming API Hal Hildebrand Vinod Mehra Jeff Lai

Upload: salesforce-developers

Post on 05-Jul-2015

757 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Build Your First Real-time App with the Streaming API

Build your first Real-Time App with

Streaming API

Hal Hildebrand

Vinod Mehra

Jeff Lai

Page 2: Build Your First Real-time App with the Streaming API

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 product or service availability, 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, new products and services, 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-Q for the most recent fiscal quarter ended July 31, 2012. This

documents and others containing important disclosures 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 presentations, 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: Build Your First Real-time App with the Streaming API

Hal, Vinod, Jeff, Alex

Salesforce R&D

Page 4: Build Your First Real-time App with the Streaming API

Before we begin

What you will need to follow along

Have your DEV Org created and ready

Install the Streaming Hands on Package

See http://bit.ly/demo-setup for complete instructions

Note!

Chrome browser support has a bug when showing maps!

Please use FireFox for this demo

See demo installation instructions at: http://bit.ly/demo-setup

Page 5: Build Your First Real-time App with the Streaming API

What are we going to build

Build two scenarios

Use geo location coordinates to plot Opportunities Real Time

• Use browser based geo location to show where Opportunities taking place

• Plot location on map based on Streaming API events

Enable Real Time updates for a Leaderboard

• Update page with sales results from different sales people

• Use CometD to listen to Streaming API and get events

See demo installation instructions at: http://bit.ly/demo-setup

Page 6: Build Your First Real-time App with the Streaming API

Short Introduction to Streaming

•Clients concerned with changes in data

• Data creation

• Data update

•Common solution is to poll for changes

• Wastes resources on both client and server

•Streaming API pushes changes to clients

• Sets up continuous queries to monitor changes

• JSON events describing changes

Page 7: Build Your First Real-time App with the Streaming API

Demo Object Model

Event Custom Object

Central Mechanism for notifications

Use Apex triggers to create Events

When monitored objects are

Created

Updated

Event Location

Captures locations for events

Page 8: Build Your First Real-time App with the Streaming API

Event Publishing Workflow

Define triggers on entities

Invoice

• After update

• After create

Ticket

• After create

EventPublisher creates Event

Page 9: Build Your First Real-time App with the Streaming API

Streaming Subscription Flow

Event is published (created)

EventUpdates topic query matches

Javascript function notifyEvent() called

Browser posts location information

Rest call to create and add the

EventLocation on the event

Javascript function postLocation() called

Page 10: Build Your First Real-time App with the Streaming API

Add Apex triggers to desired entities

Tickets

Invoices

Opportunities

Page 11: Build Your First Real-time App with the Streaming API

Streaming Push Topics

Create Push Topics to enable detection of events

EventUpdates

• SELECT Id, Name, Type__c, Timestamp__c, SObjectName__c, SObjectId__c

FROM Event__c

OpportunityWon

• Select Id, OwnerId, Amount, isWon, StageName from Opportunity

See demo installation instructions at: http://bit.ly/demo-setup

Page 12: Build Your First Real-time App with the Streaming API

Launch Workbench

Start Workbench to create a topic

https://workbench.developerforce.com/login.php

See demo installation instructions at: http://bit.ly/demo-setup

Page 13: Build Your First Real-time App with the Streaming API

View/Create Push Topics

See demo installation instructions at: http://bit.ly/demo-setup

Page 14: Build Your First Real-time App with the Streaming API

Getting GPS from Browser

Include Static Resources for CometD and get Coordinates

Page 15: Build Your First Real-time App with the Streaming API

Plotting new deals on a map

Connect and subscribe to events to plot

See demo installation instructions at: http://bit.ly/demo-setup

Page 16: Build Your First Real-time App with the Streaming API

Demo!

Use your tablet, phone or laptop browser to login to your DE org

Select the “Location Streaming” tab

Open another browser tab, login to DE org

Create a new ticket

Location is pushed to the first tab

Select “Events” tab

Select event to see map with monitoring browser locations

tagged

Page 17: Build Your First Real-time App with the Streaming API
Page 18: Build Your First Real-time App with the Streaming API

Leaderboard – Deals Page

Show deals the usual way

WonDeal Page

See demo installation instructions at: http://bit.ly/demo-setup

Page 19: Build Your First Real-time App with the Streaming API

Leaderboard – Deals Page

Streaming Enabled

See demo installation instructions at: http://bit.ly/demo-setup

Page 20: Build Your First Real-time App with the Streaming API

Leaderboard – Deals Page with Streaming API

Add Streaming API

CometD from Static Resources

See demo installation instructions at: http://bit.ly/demo-setup

Page 21: Build Your First Real-time App with the Streaming API

Leaderboard – Deals Page with Streaming API

Add Streaming API

Connect

Subscribe

Listen to Topics

See demo installation instructions at: http://bit.ly/demo-setup

Page 22: Build Your First Real-time App with the Streaming API