I am trying to replicate one example given below in streaming api. I have used all the required component, still the page is not refreshing automatically.

I am using example from below link -


Below are the code i have used -

Vf Page -

<apex:page id="PG" controller="StreamingAPIController">
<apex:form id="FRM">

<apex:includeScript value="{!URLFOR($Resource.streamapi, 'Cometd.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.streamapi, 'jquery-2.1.3.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.streamapi, 'json2.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.streamapi, 'jquery.cometd.js')}"/>

    <apex:actionFunction name="GetRefreshedAccounts" reRender="PB,PBT"/>

    <script type="text/javascript">
        $(document).ready(function() {

        // Connect to the CometD endpoint
            url: window.location.protocol+'//'+window.location.hostname+'/cometd/34.0/',
            requestHeaders: { Authorization: 'OAuth {!$Api.Session_ID}'}

        // Subscribe to a topic. JSON-encoded update will be returned in the callback
        // In this example we are using this only to track the generated event
        $.cometd.subscribe('/topic/RefreshAccounts', function(message)
            //You can use message as it will return you many attributes
            //I am just using to track that event is generated


    <apex:pageBlock id="PB">
    <apex:variable var="count" value="{!0}" />
    <apex:pageBlockTable id="PBT" value="{!getRefreshedAccount}" var="AllAcc">

        <apex:column headerValue="S.No.">
        <apex:variable var="count" value="{!count+1}" />
        <apex:column value="{!AllAcc.Name}" headerValue="Name"/>



Apex Class -

public class StreamingAPIController
    //Everytime page is reRendered it will get refreshed values of account
    public List<Account> getRefreshedAccount
        return [select Id, Name from Account LIMIT 50000] ;

    public StreamingAPIController()

PushTopic pushTopic = new PushTopic();
pushTopic.Name = 'RefreshAccounts';
pushTopic.Query = 'SELECT Id, Name FROM Account';
pushTopic.ApiVersion = 34.0;
pushTopic.NotifyForFields = 'Referenced';
insert pushTopic;

1 Answer 1


Use Jquery 1.5.1 as in the example, jquery-2.1.3.js may be the issue.

  • Eh, it is an answer to some degree. It's the same recommendation I made in the comments, but the OP never responded if they'd tried it.
    – Adrian Larson
    Jul 27, 2018 at 3:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .