Home SalesforceApex Ultimate Guide to Monitoring Platform Events using Streaming Monitor

Ultimate Guide to Monitoring Platform Events using Streaming Monitor

by Dhanik Lal Sahni
Monitoring Platform Events

Platform Events in Salesforce is a powerful feature that enables event-driven architecture within the Salesforce ecosystem. This enables integration and communication between different parts of your Salesforce org and external systems in a scalable and loosely coupled manner. Platform events are used to send and receive events in real-time.

We can monitor the usage of platform events but we can’t see platform event messages. Using the Salesforce AppExchange package Streaming Monitor we can check event data also. We can use this package to monitor all streaming events like PushTopic events, generic events, standard and custom platform events, change data capture events, and monitoring events. This post will explain how to use this package to monitor platform event data.

Use Case

ABC Company need to send order information created into Salesforce to third-party systems for further processing like invoicing, fulfilment etc. This information should be sent to third-party systems even if their system is down for some time.

Solution

We will create a platform event and push messages to the third-party system. Third-party systems can subscribe to this platform event and use it for processing. These messages are available for 72 hours so they can get all messages even system is rebooted.

The steps to monitor platform events are as below

  1. Create Platform Event
  2. Install Streaming Monitor
  3. Subscribe to Platform Event in Package
  4. Test Functionality

1. Create a Platform Event

As per the above solution, we need to send order information to the third-party system. Let us create a platform event Order Created (Order_Created_Event__e) that will be used for sending message to third party. Create the below fields in this platform event

Field LabelField APIField Data Type
Order IDOrderId__cText(255)
Product IDProductId__cText(21)
Product NameProductName__cText(255)
QuantityQuantity__cNumber(5, 0)
Platform Event Fields

This event is published when a new product order is created in Salesforce. Let us create a flow that will publish platform events when an product order is created.

Flow Creation

Create a record trigger flow on the ProductOrder object. Set flow object and entry criteria like the below table.

Configure TriggerA record is created or updated
Condition RequirementsAll Conditions Are Met (AND)
When to Run the Flow for Updated RecordsEvery time a record is updated and meets the condition requirements
Optimize the Flow forActions and Related Records
Flow Enry Crietria

The below Condition Requirements need to be set

FieldOperatorValue
Product2IdIs Nullfalse
OrderIdIs Nullfalse
Flow Entry Criteria Condition

Add the Create Record element and add values from the current record to platform event properties. Check the below image for value assignment. You can assign values based on your assignments.

Publish Platform Event in Flow | SalesforceCodex
Publish Platform Event in Flow

Save and activate this flow for publishing platfform event.

2. Install Streaming Monitor

Install Streaming Monitor from AppExchange to your Salesforce Org. It is a free app developed by Salesforce Labs. You should try this application first in sandbox org. Once successfully tested and required then install in production.

Streaming Monitor | Platform Events | SalesforceCodex
Streaming Monitor

Once it is installed it will show in the Installed Package page. Now we can test this application to monitor platform events.

3. Subscribe to the Platform Event in Streaming Monitor

We can set subscriptions to platform events from Streaming Monitor. This is lightning app and is accessible similar to other object.

This app can be used to monitor almost all events. We will subscribe to our custom platform event. Select Subscribe to a channel in actions. Set properties like below

Event typeCustom Platform event
Event nameOrder Created Event (Change based on your given name)
Streaming channelThis will automatically generated
Replay optionNo replay (default for all new messages- let this be selected)
Replay past events – this will show previous messages as well
Replay Id- This will show message after given replay id
Streaming Event Subscription in Streaming Monitor

4. Test Feature

To test this feature we need to create or update Product Order record. Once it is created or updated, it will show messages in Streaming Monitor.

References

Streaming Monitor

Platform Events

Similar Posts

Publish Platform Events from ASP.NET

Event Driven Software Architecture

Create Jira Issue in Salesforce Apex with Jira Integration

Accessing External Credential Parameters of Named Credential in Salesforce Apex

Configurable Record Picker in Lightning Web Component

Need Help?

Need some kind of help in implementing this feature, connect on my LinkedIn profile Dhanik Lal Sahni.

You may also like

Leave a Comment

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.