I'm using the Salesforce generic streaming demo to try to listen to systemTopic channels, but not able to get it to work. Tried accessing /systemTopic/TestResult and /systemTopic/Logging but could not see either. Here's the demo code: https://github.com/snugsfbay/SalesforceDurableStreamingDemo Controller:

public String channel{get; private set;}
public Id channelId{get; private set;}
public Integer replayFrom{get;set;}

public DurableGenericStreamingController() {
    this.channel = '/systemTopic/TestResult';
    this.replayFrom = -2;
    this.channelId = getStreamingChannelId(this.channel).Id;

private StreamingChannel getStreamingChannelId(String channel) {
    return [SELECT Id FROM StreamingChannel WHERE Name=:channel];

and script from the VF:

    var $j = jQuery.noConflict();
    function generateEvents(msgInputId, numMsgInputId, channelId, sessionId) {
        var pushEventsPayload = {};
        var pushEvents = [];
        for (var i=0; i < parseInt(document.getElementById(numMsgInputId).value); i++) {
            var event = {};
            event.payload = document.getElementById(msgInputId).value;
            event.userIds = [];
        pushEventsPayload.pushEvents = pushEvents;

            url: window.location.protocol+'//'+window.location.hostname+ (null != window.location.port ? (':'+window.location.port) : '') +
                '/services/data/v36.0/sobjects/StreamingChannel/'+ channelId + '/push',
            headers: {
                'Authorization': 'OAuth ' + sessionId
            type: "POST",
            data: JSON.stringify(pushEventsPayload),
            contentType: "application/json; charset=utf-8",
            dataType: "json"

API version is 36 for both the endpoint and the controller because I was testing with Logging endpoint as well.

Fails when it tries to find the ID for these channels. Any suggestions? Do you think the Lightning component for emp api would work?


I haven't tested it, but I believe the problem is with the endpoint. The code you have makes sense for a standard streaming channel that you have configured. However, this is a built in System Channel.

It won't show up in with a SOQL query against StreamingChannel.

Instead, you should try and match how the Developer Console calls it. I see a POST call to /cometd/36.0 with a request payload like:


I use /systemTopic/TestResult from a .NET application with cometD against that channel and it works well.

The example in Replay Events Sample: Code Walkthrough should be easier to adapt as it uses the channel directly rather than the StreamingChannel.

  • 1
    Thanks, I just needed to get my eyeballs pointed in the right direction. I should have been looking at the component on the VF page because that's where all the cool stuff happens, including the reference to /cometd/36.0. – snugsfbay Jun 9 '19 at 22:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.