DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • How to Integrate a Distributed Database With Event Streaming
  • Handle HL7 MLLP Messages With Mule 4
  • Data Platform: Building an Enterprise CDC Solution
  • How to Use JMS ActiveMQ With Mule 4: Part 2

Trending

  • Why Database Migrations Take Months and How to Speed Them Up
  • The Future of Java and AI: Coding in 2025
  • Beyond Code Coverage: A Risk-Driven Revolution in Software Testing With Machine Learning
  • Immutable Secrets Management: A Zero-Trust Approach to Sensitive Data in Containers

How to Use Platform Events With MuleSoft's Salesforce Connector

Learn how to use the Anypoint Connector for Salesforce for integration, and the difference between Platform Events and Streaming API Events.

By 
Nathan Nam user avatar
Nathan Nam
·
Nov. 16, 17 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
14.8K Views

Join the DZone community and get the full member experience.

Join For Free

Salesforce introduced Platform Events with its Summer '17 release (API v40). While the Anypoint Connector for Salesforce has supported Streaming API Events, the following description from Salesforce might be helpful to understand the difference between Platform Events and Streaming API Events.

Platform Events

Platform Events enable you to deliver secure, scalable, and customizable event notifications within Salesforce or through external sources. Platform Event fields are defined in Salesforce and they determine the data that you send and receive. Apps can publish and subscribe to Platform Events on the Force.com Platform using Apex or using CometD in external systems.

Streaming API Events

The Streaming API provides two types of events that you can publish and subscribe to: PushTopic and generic. PushTopic events track field changes in Salesforce records and are tied to Salesforce records. Generic events contain arbitrary payloads. Both event types don't provide the level of granular customization that Platform Events offer. You can send a custom payload with a generic event, but you can't define the data as fields. You can't define those types of events in Salesforce, and you can't use them in Apex triggers.

Anypoint Connector for Salesforce

In order to provide granular customizations for MuleSoft users, we are excited to announce the release of the Anypoint Connector for Salesforce v8.4.0, which supports receiving and publishing Platform Event messages. In this blog post, I'd like to walk you through a simple demo app, which shows you how to receive Platform Events and publish Platform Event messages with the Salesforce Connector.

Before you start with the demo app, please make sure you download the Salesforce Connector v8.4.0 from Anypoint Exchange.

After you install the Salesforce Connector, copy and paste the following XML in your Mule project, and you will see the two Mule flows in the project.

Once you load the example, let's configure the connector. To configure the Salesforce Connector, go to Global Elements, and find "Salesforce." After selecting "Salesforce," click "Edit."

In the "Salesforce: Basic Configuration," you can specify the configuration for Salesforce. You can directly add your Salesforce information in the configuration, but we recommend using the properties file to add your configuration information.

In mule-app.properties, please configure the following properties based on your Salesforce instance.

sfdc.username= sfdc.password= sfdc.token=

Now, it is time to define a Platform Event which the Salesforce Connector will listen to. For this demo app, I followed the Salesforce instructions to create and define the Platform Event called The connector in this demo app is configured to listen through the "Replay streaming channel" operation.

As Salesforce stores the Platform Event messages in 24 hours, you can replay the messages with "Replay Id." Please take a look at the previous blog post for more information.

Now you are ready to receive the platform messages from Salesforce. After you run the demo app, please go to Salesforce Workbench to publish Platform Event Messages to the Low_Ink_e.

As soon as you create a Platform Event message, you will see the following message logged in Studio. (Note: Your result might be different.)

Let's take a look at the second flow to see how the Salesforce Connector enables you to publish Platform Event messages in Mule.

When you select the "Publish platform event message" operation, the connector shows a list of Platform Events in your Salesforce instance and the metadata for the selected Platform Event. Based on the metadata, I can use DataWeave to create a platform event message in a simple way.

As soon as you hit localhost:8081/publishMessages with Postman or a browser, you will see the following logged message in Studio. (Note: Your result might be different.)

For new users, try the above example to get started, and for others, please share with us how you plan to use the Platform Events with the Salesforce Connector!

Also, be sure to explore Anypoint Exchange to see other resources you can leverage today.

Event Connector (mathematics)

Published at DZone with permission of , DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • How to Integrate a Distributed Database With Event Streaming
  • Handle HL7 MLLP Messages With Mule 4
  • Data Platform: Building an Enterprise CDC Solution
  • How to Use JMS ActiveMQ With Mule 4: Part 2

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: