3

I've implemented a simple streaming api code for subscription to the push topic using a callback function. It's realy needed because the official CotemD documentation expressly points to it:

Calling subscribe() does not mean that you have completed the subscription with the server when function returns.

If you want to be certain that the server received your subscription request (or not), you can ... pass a callback function to subscribe()

Here is my subscribe function:

subscription = jQuery.cometd.subscribe('/topic/MyPushObject', 
                                        function(message){ handleMessage(message); }, 
                                        function(subscribeReply){
    // THIS PIECE OF CODE IS NEVER CALLED
    if (subscribeReply.successful){
        console.log('subscribe success');
    }
    else{
        console.log('subscribe failed');
    }
});

I can successfully subscribe to the push topic but the callback function is never called (no console log, no break points in browser).

Am I missing something here?

  • Did you create a PushTopic record and named it 'MyPushObject'? – Simon Apr 21 '15 at 21:45
  • @SImon Of course :) It all works fine, but the callback. – Sergej Utko Apr 22 '15 at 6:27
1

The callback function feature has been added in CometD 2.8.0.

I am guessing that SalesForce uses an older version that does not have that functionality implemented.

The current CometD version is 3.0.4, and the updated CometD 3.0.x documentation is at this address.

The best thing is to ask SalesForce what exact CometD version they are using, and if it is old, to update it to newer versions - to provide bug fixes and more functionalities.

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.