Final Up to date on April 30, 2023 by Rakesh Gupta
Large Thought or Enduring Query:
- The way to configure the person and batch dimension for Platform Occasion Set off?
After studying this weblog, you’ll be capable to:
- Perceive the batch dimension for platform occasion set off
- Override the default working person for platform occasion set off
- Create the PlatformEventSubscriberConfig through REST API
- and rather more
Jestilla Zetkin is working as a Salesforce Architect at Gurukul On Cloud (GoC). Just lately she confronted challenges whereas working with platform occasions, primarily governer limits. She desires to learn to configure the batch dimension for the platform occasion set off. On this train, we are going to arrange the batch dimension for the next:
- Apex Set off
- LeadGenerationEventTrigger on Lead_Generation__e
- Batch Measurement: 50
- Working Person: Integration Person
What’s Platform Occasions?
Occasion-driven architectures have develop into highly regarded in recent times, and for an excellent cause. It’s based mostly on the fire-and-forget sample. Firing an occasion and letting every system deal with enterprise logic means that you can hold unrelated programs decoupled and will help simplify the structure.
Platform occasions allow you to ship safe, scalable, and customizable occasion notifications inside Salesforce or from exterior sources. Apps can publish and subscribe to Platform Occasions on the Salesforce platform utilizing Apex, Circulation, or in an exterior system utilizing CometD. If you wish to study extra about Platform Occasion, try the Trailhead Module.
What’s the Default Batch Measurement for Platform Occasion Set off?
By default, the platform occasion set off runs because the Automated Course of system person with a batch dimension of two,000 occasion messages. Typically it’s required to vary the person and batch dimension to bypass governer limits or different challenges.
Salesforce means that you can override the default working person and batch dimension of a platform occasion Apex set off with PlatformEventSubscriberConfig in Tooling API or Metadata API to configure the set off.
You may specify any energetic person within the Salesforce org. The set off runs in a system context with privileges to entry all information whatever the person’s object and field-level permissions. You may specify a customized batch dimension from 1 via 2,000. The batch dimension is the utmost variety of occasion messages that may be despatched to a set off in a single execution.
Perceive PlatformEventSubscriberConfig Object
Let’s take a pause right here, familiarize your self with the PlatformEventUsageMetric Tooling API object in Salesforce. It represents configuration settings for a platform occasion Apex set off, together with the batch dimension and the set off’s working person.
|BatchSize||A customized batch dimension, from 1 via 2,000, for the platform occasion Apex set off. The batch dimension corresponds to the utmost variety of occasion messages that may be despatched to a set off in a single execution. The default batch dimension is 2,000 for platform occasion triggers.|
|DeveloperName||The distinctive title for the PlatformEventSubscriberConfig object.|
|MasterLabel||Label for PlatformEventSubscriberConfig. Within the UI, this area is Platform Occasion Subscriber Configuration.|
|PlatformEventConsumerId||The ID of the platform occasion Apex set off to configure.|
|UserId||The ID of the person that the platform occasion Apex set off runs as. By default, the platform occasion set off runs because the Automated Course of entity. Setting the working person to a particular person has these advantages:
PlatformEventSubscriberConfig elements have the suffix .platformEventSubscriberConfig and are saved within the PlatformEventSubscriberConfigs folder.
This PlatformEventSubscriberConfig element has the label LeadGenerationEventTriggerConfig. It incorporates the configuration of a platform occasion set off, LeadGenerationTrigger, and specifies the batch dimension and person.
<?xml model="1.0" encoding="UTF-8"?> <PlatformEventSubscriberConfig xmlns="http://cleaning soap.sforce.com/2006/04/metadata"> <platformEventConsumer>LeadGenerationTrigger</platformEventConsumer> <batchSize>50</batchSize> <masterLabel>LeadGenerationEventTriggerConfig</masterLabel> <person>email@example.com</person> <isProtected>false</isProtected> </PlatformEventSubscriberConfig>
Guided Apply (We-do):
So as to add a configuration, carry out a POST request as talked about under:
- Open the Workbench and log in along with your Trailhead playground username and password.
- Just remember to’ve chosen the Manufacturing for Atmosphere possibility.
- Navigate to Utilities tab and choose the REST Explorer possibility.
- Choose the next choices:
- Select an HTTP methodology to carry out on the REST API service URI under: POST
- URL: /companies/knowledge/v58.0/tooling/sobjects/PlatformEventSubscriberConfig
- Physique: Present the values within the request physique. This instance request configures an current set off with the batch dimension of 50 and specifies the ID of a working person.
- The place:
- 01qB0000000Zcug, Apex set off on Lead_Generation__e
- 005B00000015gt8, is person Id of Integration Person
- Click on Execute.
You may question retrieve the configurations in your org with SOQL. If querying from the Developer Console Question Editor, guarantee you choose Use Tooling API. This instance question retrieves all configurations arrange in your Salesforce org.
I need to hear from you!
What’s one factor you realized from this publish? How do you envision making use of this new information in the true world? Be at liberty to share within the feedback under.