In this post, we will see the solutions of Module: Platform Events Basics -Salesforce Answers
#1.Understand Event-Driven Software Architecture
Q1)What are the components of an event-based architecture?
I)Event bus, event producer, event consumer, and event builder
II)Event producer and event consumer
III)Event producer, event consumer, and Apex trigger
IV)Event producer, event consumer, event, event message, event channel, and event bus
V)Platform events
[bg_collapse view=”button-orange” color=”#4a4949″ expand_text=”Show Answers” collapse_text=”Close Answer” ]
IV)Event producer, event consumer, event, event message, event channel, and event bus
[/bg_collapse]
Q2)What are some benefits of an event-driven software architecture?
I)It decouples event producers from channels.
II)It decouples event producers from event consumers, which have several dependencies on each other.
III)It enables near real-time communication between publishers and subscribers by requiring the writing of complex logic.
IV)It enables the broadcasting of news messages.
V)It enables near real-time communication, simplifying communication by decoupling event producers from event consumers.
[bg_collapse view=”button-orange” color=”#4a4949″ expand_text=”Show Answers” collapse_text=”Close Answer” ]
V)It enables near real-time communication, simplifying communication by decoupling event producers from event consumers.
[/bg_collapse]
Q3)For which of these scenarios would you use platform events?
I)Schedule a calendar event
II)Broadcast messages with a payload containing only the message body
III)Subscribe to events tied to Salesforce records only
IV)Publish and subscribe to events that are within or external to Salesforce
V)Use Apex and Streaming API
[bg_collapse view=”button-orange” color=”#4a4949″ expand_text=”Show Answers” collapse_text=”Close Answer” ]
IV)Publish and subscribe to events that are within or external to Salesforce
[/bg_collapse]
Q4)What are some characteristics of a platform event message?
I)It is similar to a Salesforce object record, it is not viewable in the user interface, and it can’t be edited or deleted.
II)It is an object, it can’t be edited or deleted, and it is viewable in the user interface.
III)It is a Salesforce object record, it is not viewable in the user interface, and it can be edited but not deleted.
IV)It is a one-of-a-kind custom object record!
V)It is similar to a Salesforce object record, it is not viewable in the user interface, and it can’t be edited, but it can be deleted.
[bg_collapse view=”button-orange” color=”#4a4949″ expand_text=”Show Answers” collapse_text=”Close Answer” ]
I)It is similar to a Salesforce object record, it is not viewable in the user interface, and it can’t be edited or deleted.
[/bg_collapse]
#2.Define and Publish Platform Events
Hands-on Challenge
Earn+500 points
YOUR CHALLENGE
Define a platform event
Create a platform event with two fields. An order app sends a message of this event to notify a Salesforce app that an order has been shipped. In this challenge, you create only the platform event.
#Create Order Event Platform Event:
#Label: Order Event
#Plural Label: Order Events
#Object Name: Order_Event
#Description: Information about a customer order
#Publish Behavior: Publish After Commit
#Create Order Number and Has Shipped fields:
#Field Type: Text
#Label: Order Number
#Length: 10
#Name: Order_Number
#Field Type: Checkbox
#Label: Has Shipped
#Name: Has_Shipped
My Trailhead Playground 1
Last used on 11/26/2021
#3.Subscribe to Platform Events
Hands-on Challenge
Earn+500 points
YOUR CHALLENGE
Subscribe to a Platform Event in an Apex trigger
Your Salesforce app uses an Apex trigger to listen to events. Once your app receives the notification from the order system through the Apex trigger, it creates a task to follow up on the order shipment.
#Create an Apex trigger for Order_Event__e:
#Name: OrderEventTrigger
This Apex trigger should be similar to the CloudNewsTrigger Apex trigger, but operates on the Order_Event__e event and creates tasks instead of cases.
#If the order has shipped (event.Has_Shipped__c == true), create a task with the following values:
#Priority: ‘Medium’
#Subject: ‘Follow up on shipped order ‘ + event.Order_Number__c
#OwnerId: event.CreatedById
#Note: You are assigning the task OwnerId to the same user who published the event. This step keeps things simple so you don’t have to perform any prerequisites.
My Trailhead Playground 1
Last used on 11/26/2021
Complete the Challenge to Earn 500Points