Git Product home page Git Product logo

salesforcedurablegenericdemo's Introduction

Salesforce Durable Generic Streaming Demo

This repository contains all the code you need to set up a Durable Generic Streaming client inside of a Visualforce page in your Salesforce Org. The Durable Generic Streaming adds the capability to replay any of the messages sent to the Generic Channel for the last 24 hours.

This is handled through the use of an Event ID. Every event sent through the Generic Streaming system will have an associated ID. With durability, you will have the ability to provide an Event ID (ostensibly the last ID that your client has received) and the system will send every event that has happened in the last 24 hours after that specific ID.

If you do not provide and ID, or the ID you provide is -1, your client will be subscribed to the tip of the queue (you will receive all new messages. If you provide an ID of -2, we resend ALL events that happened in the last 24 hours.

Please note that this is a current Beta feature in Salesforce, and in order to sucessfully subscribe to a durable channel, you will need to have your org enabled for the new feature. To do so, please contact [email protected].

Demo Instructions

  1. Download this repo as zip file
    • This contains all of the needed code to run the client inside of Salesforce
  2. Deploy the code to an enabled Winter '16 org using the MdAPI through Workbench, Force.com IDE, or Ant Migration Tool
  3. Assign the included StreamingDurableGenericDemo permission set to your user
  4. Create the /u/TestStreaming StreamingChannel by subscribing to that channel name
    • You can create the channel by using the Workbench and going to Queries > Streaming Push Topics and selecting Generic Subscriptions. Enter the subscription as /u/TestStreaming and click 'Subscribe' (this will create the channel)
    • You can also create the StreamingChannel in the Salesforce UI. See the Generic Streaming Documentation for more information
  5. Push an event to the new channel
    • Query the ID of the channel by using the Workbench REST Explorer and doing a GET to /services/data/v35.0/sobjects/StreamingChannel. In thenRecentItems response, you should see the ID for /u/TestStreaming
    • Do a POST to /services/data/v35.0/sobjects/StreamingChannel/<CHANNEL_ID>/push with a payload of:
      • { "pushEvents": [{"payload": "first push"} ]}
  6. Navigate to /apex/StreamingDurableGenericDemo. This Visualforce page will auto-subscribe to /u/TestStreaming using Durable Generic Streaming
    • This could fail if you haven't created the streaming channel and haven't pushed at least 1 event to that channel)
  7. Generate new events using on-page controls.
  8. Update replay subscription settings by changing the Replay From attribute. This will change where in the event stream you are subscribed to
    • -2 will replay from eariest available event
    • -1 (or no ID) will replay only new events
    • Provide a specific Event ID to replay all events after that specific ID

Open Issues to Remember

  1. This is still a Salesforce Beta Feature
    • It needs to be enabled manually on every org
    • Issues should be communicated directly to the Product Manager, Jay Hurst ([email protected])
  2. You have to push at least one event to a channel in order for the channel to work with durable generic streaming. This is resolved with the Spring'16 release
  3. You cannot replay using an ID outside of your event stream window (if you provide an ID from 2 weeks ago, it will be invalid)
  4. The current event stream window is 24 hours

salesforcedurablegenericdemo's People

Contributors

dcarroll avatar jthurst01 avatar stanlemon avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

salesforcedurablegenericdemo's Issues

Generic Streaming without replay

It seems that former streaming API endpoint /cometd/<API_VERSION> is not working for generic streaming currently (which was working before Spring '16 update). Does it mean all generic streaming subscribers should move their endpoint from /cometd/<API_VERSION> to /cometd/replay/<API_VERSION> even if they don't use durable streaming ?

Workbench documentation doesn't match

The README current reads:

You can create the channel by using the Workbench and going to Queries > Streaming Push Topics and selecting Generic Subscriptions. Enter the subscription as /u/TestStreaming and click 'Subscribe' (this will create the channel)

However when I use the Workbench I do not see an option for "Generic Subscriptions", nor was I able to figure out where the enter the new subscription. See the attached screen shot.

screen shot 2016-01-15 at 2 08 56 pm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.