Newer Version Available
PlatformEventSubscriberConfig
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. |
| numPartitions | int | Specifies the number of parallel subscriptions, or partitions, that are created
internally for an Apex trigger. Use this field to set up parallel subscriptions for
the platform event Apex trigger. It can be an integer from 1 through 10. See Platform Event Processing at
Scale with Parallel Subscriptions for Apex Triggers in the Platform
Events Developer Guide. The default value is 1. This field is available in API version 62.0 and later. |
| partitionKey | string | Can be the standard EventUuid field or a
required custom field of the custom platform event that the Apex trigger subscribes
to. For the standard EventUuid field, the partition key format
is the field name without the event name: EventUuid. For a custom field, the partition key includes the event
name as a prefix in this format: EventName__e.FieldName__c. Based
on the field’s generated hash value, the system determines which partition to send
the event to. Use this field to specify the platform event field that is used as a
partition key for parallel subscriptions. See Platform Event Processing at Scale with Parallel
Subscriptions for Apex Triggers in the Platform Events Developer
Guide. The default value is EventUuid. This field is available in API version 62.0 and later. |
| 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:
|
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>66.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>66.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>66.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.