Deep-dive on the Next Gen Platform. Join the Webinar!

Skip Navigation
Show nav
Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
    • .NET
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log inorSign up
Hide categories

Categories

  • Heroku Architecture
    • Compute (Dynos)
      • Dyno Management
      • Dyno Concepts
      • Dyno Behavior
      • Dyno Reference
      • Dyno Troubleshooting
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Developer Tools
    • Command Line
    • Heroku VS Code Extension
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery & Integration (Heroku Flow)
    • Continuous Integration
  • Language Support
    • Node.js
      • Working with Node.js
      • Troubleshooting Node.js Apps
      • Node.js Behavior in Heroku
    • Ruby
      • Rails Support
      • Working with Bundler
      • Working with Ruby
      • Ruby Behavior in Heroku
      • Troubleshooting Ruby Apps
    • Python
      • Working with Python
      • Background Jobs in Python
      • Python Behavior in Heroku
      • Working with Django
    • Java
      • Java Behavior in Heroku
      • Working with Java
      • Working with Maven
      • Working with Spring Boot
      • Troubleshooting Java Apps
    • PHP
      • PHP Behavior in Heroku
      • Working with PHP
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
    • .NET
      • Working with .NET
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
      • Migrating to Heroku Postgres
    • Heroku Key-Value Store
    • Apache Kafka on Heroku
    • Other Data Stores
  • AI
    • Working with AI
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
      • Single Sign-on (SSO)
    • Private Spaces
      • Infrastructure Networking
    • Compliance
  • Heroku Enterprise
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
  • Integrating with Salesforce
  • Publish and Subscribe to Salesforce Platform Events

Publish and Subscribe to Salesforce Platform Events

English — 日本語に切り替える

Last updated November 09, 2023

Table of Contents

  • When to Use
  • Publishing Platform Events From Heroku
  • Subscribing to Platform Events
  • Limits & Considerations
  • Learn More

You can architect apps using an event-driven approach with the Salesforce enterprise messaging platform. Platform Events provides a powerful technique for integrating business processes in Salesforce, or for integrating such processes with external systems, such as Heroku apps. The architecture is suitable for large distributed systems because it decouples event producers from event consumers, simplifying the communication model in connected systems.

Heroku applications can behave as event producers, event consumers, or some combination of the two.

When to Use

You want to build a modern integration with the Salesforce enterprise messaging platform. The messaging platform lets you build modular integrations with clean integration boundaries using an event bus, instead of point-to-point integrations.

Publishing Platform Events From Heroku

Publish platform events with Pub/Sub API using a programming language that Pub/Sub API and Heroku support, including Java, Node.js, Go, and Python. Based on gRPC API and HTTP/2, Pub/Sub API provides a single interface to efficiently publish and deliver binary event messages in the Apache Avro format. For more information, see Publish Event Messages with Pub/Sub API in the Platform Events Developer Guide.

To write an app for publishing events, you can start with the getting started code example provided for a supported language in Language Support. Then modify the example to add your code to create a Pub/Sub API client and publish an event with the Publish RPC method or the PublishStream RPC method. For Pub/Sub API client code examples, see the Pub/Sub API GitHub repo. Also, check out the E-Bikes Manufacturing Demo app which you can deploy to Heroku. The E-Bikes Manufacturing app is a Node app that uses the Lightning Web Runtime. For more information, see Platform Event Samples in the Platform Events Developer Guide.

Subscribing to Platform Events

Subscribe to platform events and change data capture events with Pub/Sub API using a programming language that Pub/Sub API and Heroku support, including Java, Node.js, Go, and Python. Based on gRPC API and HTTP/2, Pub/Sub API provides a single interface to efficiently publish and deliver binary event messages in the Apache Avro format. For more information, see Subscribe to Platform Event Notifications with Pub/Sub API in the Platform Events Developer Guide.

To write an app for subscribing to events, you can start with the getting started code example provided for a supported language in Language Support. Then modify the example to add your code for subscribing to events using the Subscribe RPC method. For Pub/Sub API client code examples, see the Pub/Sub API GitHub repo. Also, check out the E-Bikes Manufacturing Demo app which you can deploy to Heroku. The E-Bikes Manufacturing app is a Node app that uses the Lightning Web Runtime. For more information, see Platform Event Samples in the Platform Events Developer Guide. The E-Bikes app subscribes to change data capture events for incoming orders and then publishes platform events to update orders. You can modify the topic parameter to subscribe to a specific platform event or change event.

Limits & Considerations

Read the Salesforce docs that describe what to consider when building with Platform Events, including avoiding infinite trigger loops, API limits, and more.

Security and Heroku/Salesforce integrations shows how to secure this integration.

Learn More

  • Platform Events Developer Guide
  • Pub/Sub API Developer Guide
  • Change Data Capture Developer Guide

Keep reading

  • Integrating with Salesforce

Feedback

Log in to submit feedback.

Using the Salesforce REST API with Heroku Salesforce Functions Retirement

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure
  • .NET

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing
  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Github
  • LinkedIn
  • © 2025 Salesforce, Inc. All rights reserved. Various trademarks held by their respective owners. Salesforce Tower, 415 Mission Street, 3rd Floor, San Francisco, CA 94105, United States
  • heroku.com
  • Legal
  • Terms of Service
  • Privacy Information
  • Responsible Disclosure
  • Trust
  • Contact
  • Cookie Preferences
  • Your Privacy Choices