0

I haven't used the Streaming API yet. I was just researching on it actually and I like the option for PushTopics. However it's not clear to me what's the advantage/difference using that versus a process that gets started from a trigger.

Example scenario:
My_Object__c.Reference_Number__c gets modified and I want to update the value of this field in an outside system. Say storage table in Azure/AWS.

I can do this in the following manner: Use a trigger to fire a @future/queueable method that will make a REST API POST callout. I think that can be dangerous because the async methods might not execute in the same order the field was modified, say it was modified twice in a row. So ideally I would schedule a job to execute later to get the most current data.

Is PushTopic a better option for such a process and what would be the advantages? I see that there can be <100 PushTopics(depends on the edition) per org, what other limitations are there that should be taken into consideration?

  • 2
    Salesforce CDC seems like good solution for this, trailhead.salesforce.com/en/content/learn/modules/… It uses same cometD which is used by streaming api – Pranay Jaiswal Feb 14 at 19:50
  • 1
    Callout and Streaming are both designed for different use cases. It will largely depend on what is your use case here. If you want to push data to an external system, then you will need callouts here. If the external system wants to fetch data from Salesforce based on a notification, then you use Streaming here. – Jayant Das Feb 14 at 20:05
  • @PranayJaiswal Thank you I am going through that trail now. – Arthlete Feb 14 at 20:53
  • 1
    PushTopic is SOQL based, CDC will only send you the changed_field thus lighter payload. – Pranay Jaiswal Feb 14 at 21:19
  • 1
    One difference that matters sometimes... with Streaming API, a subscriber can subscribe from behind a firewall, but you can't call a web service located behind a firewall (not without jumping through hoops). – Mike Lockett Feb 17 at 18:56

Your Answer

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

Browse other questions tagged or ask your own question.