Publish Industry Data to Force.com Apps with Data Services on Heroku
Enable your Force.com app customers to subscribe to a centralized data repository powered by Heroku. Learn how to leverage Postgres, encrypted data at rest and process scheduling to secure your data, track subscribers and push data updates to Salesforce orgs.
Lynn Cohen (@slcohen) enables ISV partners in the Healthcare and Finance industry verticals to build awesome Salesforce1 apps. She has extensive experience in the Healthcare and Life Sciences industry and has worked with top finance firms in the NY, NJ, CT area.
Independent Software Vendors providing industry specific Force.com apps often have valuable data to distribute to their customers for utilization in their apps and other integrated solutions, such as Sales and Service Cloud, on the Salesforce.com platform. A hub and spoke architecture is an efficient approach to support this data-based business model: master data is curated and managed on a central system and customers subscribe to the data service and receive periodic refreshes of the data in their Salesforce.com orgs.
While the Force.com platform provides everything needed to build compelling mobile and desktop apps, Heroku supplies infrastructure for highly scalable and available services. As an illustration of applying Force.com and Heroku to the data subscription business model, an open-source reference architecture is available for download which implements a central repository of Physician data, a common use-case in the Healthcare industry. The reference architecture consists of 5 components:
- Web server for maintaining Physician records, registering Salesforce.com orgs with the subscription service, and responding to RESTful requests from Salesforce.com orgs.
- Refresh worker process to push updated Physician records to subscribed orgs.
- Heroku Scheduler, an optional Heroku add-on, similar to cron jobs on Unix. The Scheduler can be used for automatically running the Refresh worker process.
- Postgres database with encryption-at-rest extension.
- Force.com app implementing the subscription workflow and maintaining a local copy of Physician records.
How Does the Data Flow?
The data flow of Physician records is illustrative of the general data subscription pattern:
- Users of the Force.com app search for Physicians, the data service returns matching records, and then the user selects which records meet their criteria and subscribes to those records.
- The data service tracks subscriptions to Physician records at an org-ID + Physician-record-ID level of granularity.
- Periodically, the data service scans the master list of Physician records for updates and distributes those updates to the subscribed orgs. This refresh process tracks the last update to each org for each Physician record to minimize the amount of data pushed to each org.
Web server processes run within a dyno (virtual Linux server) on Heroku, and the number of dynos can be scaled to match HTTP request load. The dyno manager, part of the Heroku platform, automatically spins web server processes up and down and load balances HTTP requests across dynos.
Web server applications should be written to be stateless, which is particularly important when process startup/shutdown and routing of requests is managed by the infrastructure. This reference architecture uses Postgres as the persistent store for all application state as well as the central repository of Physician records. By choosing from one of many Heroku Postgres plans and add-ons, the required level of availability and performance is also configurable.
The web server and refresh processes are both written in node.js using the Express framework as well as other open source modules for Salesforce.com API calls and Postgres interactions. Non-blocking I/O is a core-coding paradigm in node.js, which further leads to more responsive systems.
Searching and matching people information is a large body of knowledge in itself. The supplied reference architecture supports common search use cases (name, postal code), but Postgres add-ons are available for more sophisticated searching. The pg_trgm add-on provides functions and operators for determining similarity of text based on trigrams (three consecutive characters). Similarly, the fuzzystrmatch add-on provides functions for determining similarity of text using soundex, metaphone, and other methods.
How to Get the Reference Architecture
The reference architecture is available as open source on github. Using git, clone the following repository and follow the installation instructions in the README file:
Source code for the Force.com app is available in the following repository: