HerokuScott PersingerProblem & solution
Heroku Connect: Event-driven Data Sync For Force.com
Summary
Heroku Connect synchronizes data in both directions between Salesforce (Force.com) and Heroku Postgres, but its original polling design trades simplicity and reliability for synchronization latency, wasted API calls, and unnecessary database queries. The post presents an event-driven alternative using the Force.com Streaming API and PostgreSQL’s LISTEN/NOTIFY system. For Salesforce, Heroku Connect automatically creates a PushTopic per synchronized table, subscribes with Node.js and NForce, and dispatches Redis tasks when notifications arrive. Those events act as change signals rather than complete data transfers: workers query the Force.com SOAP API because streaming has limitations and subscribers may miss events. On Postgres, PL/pgSQL trigger functions call pg_notify after DML, while node-postgres listens on named channels; the system supports added UPDATE and DELETE triggers, though triggers are still required.
Context
Heroku Connect originally used polling to detect changes between Salesforce and Heroku Postgres. Although polling was considered simple and reliable, it caused high synchronization latency or wasted API calls and database queries, depending on the polling interval.
Approach / What changed
The design uses Force.com Streaming API PushTopics as change notifications for Salesforce and PostgreSQL LISTEN/NOTIFY for database events. Node.js subscribers process notifications, Redis dispatches synchronization tasks, workers query the Force.com SOAP API for current data, and PL/pgSQL triggers publish Postgres changes through named channels.
Takeaways
Force.com PushTopics are generated automatically from the synchronized table and configured to notify on create, update, and delete operations.
Streaming notifications are used as signals to query current data through the Force.com SOAP API because event payloads have limitations and subscribers can miss events while offline.
Postgres LISTEN/NOTIFY requires database-side publishing logic; PL/pgSQL triggers call pg_notify, while node-postgres registers notification handlers and subscribes to channels.
Source and freshness
- Source
- heroku.com
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.