Newer Version Available

This content describes an older version of this product. View Latest

PlatformEventSubscriberConfig

Represents configuration settings for a platform event Apex trigger, including the batch size and the trigger’s running user.
This type extends the Metadata metadata type and inherits its fullName field.

Where possible, we changed noninclusive terms to align with our company value of Equality. We maintained certain terms to avoid any effect on customer implementations.

Important

File Suffix and Directory Location

PlatformEventSubscriberConfig components have the suffix .platformEventSubscriberConfig and are stored in the PlatformEventSubscriberConfigs folder.

Version

PlatformEventSubscriberConfig components are available in API version 51.0 and later.

Fields

Field Name Field Type Description
batchSize int A custom batch size, from 1 through 2,000, for the platform event Apex trigger. The batch size corresponds to the maximum number of event messages that can be sent to a trigger in one execution. The default batch size is 2,000 for platform event triggers.

We don't recommend setting the batch size to 1 to process one event at a time. Small batch sizes can slow down the processing of event messages.

isProtected boolean (Inherited field.) Indicates whether this component is protected (true) or not (false). Protected components can’t be linked to or referenced by components created in a subscriber org. A developer can delete a protected component in a future release without worrying about failing installations. However, once a component is marked as unprotected and is released globally, the developer can’t delete it.
masterLabel string Required. The label for the PlatformEventSubscriberConfig component.
platformEventConsumer string Required. The full name of the platform event Apex trigger to configure.
user string The username of the user that the platform event Apex trigger runs as. By default, the platform event trigger runs as the Automated Process entity. Setting the running user to a specific user has these benefits:
  • Records are created or modified as this user.
  • Records with OwnerId fields have their OwnerId fields populated to this user when created or modified.
  • Debug logs for the trigger execution are created by this user.
  • You can send email from the trigger, which isn’t supported with the default Automated Process user.

Declarative Metadata Sample Definition

This PlatformEventSubscriberConfig component has the label OrderEventTriggerConfig. It contains the configuration of a platform event trigger, OrderEventTrigger, and specifies the batch size and user.

1<?xml version="1.0" encoding="UTF-8"?>
2<PlatformEventSubscriberConfig xmlns="http://soap.sforce.com/2006/04/metadata">
3    <platformEventConsumer>OrderEventTrigger</platformEventConsumer>
4    <batchSize>200</batchSize>
5    <masterLabel>OrderEventTriggerConfig</masterLabel>
6    <user>user@example.com</user>
7    <isProtected>false</isProtected>
8</PlatformEventSubscriberConfig>

PlatformEventSubscriberConfig references an Apex trigger, which depends on a platform event. If the referenced items exist in the Salesforce org, you can deploy the PlatformEventSubscriberConfig component. This package.xml specifies the PlatformEventSubscriberConfig component.

1<?xml version="1.0" encoding="UTF-8"?>
2<Package xmlns="http://soap.sforce.com/2006/04/metadata">
3    <types>
4        <name>PlatformEventSubscriberConfig</name>
5        <members>OrderEventTriggerConfig</members>
6    </types>
7    <version>61.0</version>
8</Package>

If the referenced trigger and platform event don’t exist in the org, include their definitions in the package. Otherwise, the deployment fails. This example package.xml includes all the referenced components.

  • CustomObject represents the platform event.
  • CustomField represents a custom field defined on the platform event.
  • ApexTrigger represents the platform event trigger.
  • PlatformEventSubscriberConfig represents the configuration options for the platform event trigger.
1<?xml version="1.0" encoding="UTF-8"?>
2<Package xmlns="http://soap.sforce.com/2006/04/metadata">
3    <types>
4        <name>CustomObject</name>
5        <members>PlatformEvent__e</members>
6    </types>
7    <types>
8        <name>CustomField</name>
9        <members>PlatformEvent__e.Message__c</members>
10    </types>
11    <types>
12        <name>ApexTrigger</name>
13        <members>OrderEventTrigger</members>
14    </types>
15    <types>
16        <name>PlatformEventSubscriberConfig</name>
17        <members>OrderEventTriggerConfig</members>
18    </types>
19    <version>61.0</version>
20</Package>

To specify all PlatformEventSubscriberConfig components, use the wildcard character, as shown in this example.

1<?xml version="1.0" encoding="UTF-8"?>
2<Package xmlns="http://soap.sforce.com/2006/04/metadata">
3    <types>
4        <name>PlatformEventSubscriberConfig</name>
5        <members>*</members>
6    </types>
7    <version>61.0</version>
8</Package>

Wildcard Support in the Manifest File

This metadata type supports the wildcard character * (asterisk) in the package.xml manifest file. For information about using the manifest file, see Deploying and Retrieving Metadata with the Zip File.