This applies to Mule 4, Anypoint Studio 7.x
Salesforce Connector can subscribe to Salesforce Platform Events, in order to receive events from Salesforce. This article explains how to Subscribe to Salesforce Platform Events in Mule Application flow.
In this article, please follow an example in Trailhead Define and Publish Platform Events.
1. Login to Salesforce and create a Salesforce Platform Events. Please follow the example in the Trailhead to create a Platform Events “Cloud_News__e”.
2. Create a Mule application
2-1. Create a component Subscribe Channel, then specify “/event/Cloud_News__e” as Streaming channel.
2-2. Create a logger component to show payload, so that we will see the received message on Console.
Example)
<flow name="SampleFlow" doc:id="d25ff96a-aec9-45ee-89f2-74080fb83b45" > <salesforce:subscribe-channel doc:name="Subscribe channel" doc:id="cb21f452-9280-41f8-ba52-93c49a03ea38" config-ref="Salesforce_Config" streamingChannel="/event/Cloud_News__e"/> <logger level="INFO" doc:name="Logger" doc:id="5ebd77bf-87de-4f55-ab81-2af3abbe2bee" message="#[payload]"/> </flow>
3. As written in the above Trailhead content, Publish a Platform Event Message to “Cloud_News__e“. You can use Apex code, Process, Flow, or Salesforce APIs. For example, you can request POST with the below body.
{
"Location__c" : "Mountain City",
"Urgent__c" : true,
"News_Content__c" : "Lake Road is closed due to mudslides."
}
4. You will see something like below in the Console log, which is equivalent to the above POST body.
INFO 2019-10-26 16:11:50,483 [[MuleRuntime].cpuLight.05: [test].SampleFlow.CPU_LITE @2b42bef0]
[event: e00096e0-f7bf-11e9-b534-8c85907d741e] org.mule.runtime.core.internal.processor.LoggerMessageProcessor:
{data={schema=eGRz2Sfoy-YO9mVvH8J4fg,
payload=
{News_Content__c=Lake Road is closed due to mudslides.,
CreatedById=0050o00000U3Q8vAAF,
CreatedDate=2019-10-26T07:12:01.026Z,
Location__c=Mountain City, Urgent__c=true},
event={replayId=49544589}},
channel=/event/Cloud_News__e}
001116948

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.